Browse Source

Clippy + appveyor

index-subcmd
Vincent Prouillet 7 years ago
parent
commit
0aef05ac8e
4 changed files with 13 additions and 13 deletions
  1. +2
    -2
      appveyor.yml
  2. +4
    -4
      benches/gutenberg.rs
  3. +1
    -1
      src/cmd/serve.rs
  4. +6
    -6
      src/main.rs

+ 2
- 2
appveyor.yml View File

@@ -23,9 +23,9 @@ environment:
install:
- ps: >-
If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') {
$Env:PATH += ';C:\msys64\mingw64\bin'
$Env:PATH += ';C:\msys64\mingw64\bin;C:\Program Files\Git\mingw64\bin'
} ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') {
$Env:PATH += ';C:\msys64\mingw32\bin'
$Env:PATH += ';C:\msys64\mingw32\bin;C:\Program Files\Git\mingw64\bin'
}
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
- rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION%


+ 4
- 4
benches/gutenberg.rs View File

@@ -14,7 +14,7 @@ use gutenberg::{Site, populate_previous_and_next_pages};
fn bench_loading_test_site(b: &mut test::Bencher) {
let mut path = env::current_dir().unwrap().to_path_buf();
path.push("test_site");
let mut site = Site::new(&path).unwrap();
let mut site = Site::new(&path, "config.toml").unwrap();


b.iter(|| site.load().unwrap());
@@ -25,7 +25,7 @@ fn bench_loading_test_site(b: &mut test::Bencher) {
fn bench_building_test_site(b: &mut test::Bencher) {
let mut path = env::current_dir().unwrap().to_path_buf();
path.push("test_site");
let mut site = Site::new(&path).unwrap();
let mut site = Site::new(&path, "config.toml").unwrap();
site.load().unwrap();
let tmp_dir = TempDir::new("example").expect("create temp dir");
let public = &tmp_dir.path().join("public");
@@ -39,9 +39,9 @@ fn bench_building_test_site(b: &mut test::Bencher) {
fn bench_populate_previous_and_next_pages(b: &mut test::Bencher) {
let mut path = env::current_dir().unwrap().to_path_buf();
path.push("test_site");
let mut site = Site::new(&path).unwrap();
let mut site = Site::new(&path, "config.toml").unwrap();
site.load().unwrap();
let mut pages = site.pages.values().map(|p| p.clone()).collect::<Vec<_>>();
let mut pages = site.pages.values().cloned().collect::<Vec<_>>();
pages.sort_by(|a, b| a.partial_cmp(b).unwrap());

b.iter(|| populate_previous_and_next_pages(pages.as_slice(), false));


+ 1
- 1
src/cmd/serve.rs View File

@@ -47,7 +47,7 @@ fn rebuild_done_handling(broadcaster: &Sender, res: Result<()>, reload_path: &st
}}"#, reload_path)
).unwrap();
},
Err(e) => unravel_errors("Failed to build the site", e, false)
Err(e) => unravel_errors("Failed to build the site", &e, false)
}
}



+ 6
- 6
src/main.rs View File

@@ -35,7 +35,7 @@ fn report_elapsed_time(instant: Instant) {
}

////Display an error message, the actual error and then exits if requested
fn unravel_errors(message: &str, error: Error, exit: bool) {
fn unravel_errors(message: &str, error: &Error, exit: bool) {
console::error(message);
console::error(&format!("Error: {}", error));
for e in error.iter().skip(1) {
@@ -74,24 +74,24 @@ fn main() {
("init", Some(matches)) => {
match cmd::create_new_project(matches.value_of("name").unwrap()) {
Ok(()) => console::success("Project created"),
Err(e) => unravel_errors("Failed to create the project", e, true),
Err(e) => unravel_errors("Failed to create the project", &e, true),
};
},
("build", Some(_)) => {
console::info("Building site...");
let start = Instant::now();
match cmd::build(&config_file) {
match cmd::build(config_file) {
Ok(()) => report_elapsed_time(start),
Err(e) => unravel_errors("Failed to build the site", e, true),
Err(e) => unravel_errors("Failed to build the site", &e, true),
};
},
("serve", Some(matches)) => {
let interface = matches.value_of("interface").unwrap_or("127.0.0.1");
let port = matches.value_of("port").unwrap_or("1111");
console::info("Building site...");
match cmd::serve(interface, port, &config_file) {
match cmd::serve(interface, port, config_file) {
Ok(()) => (),
Err(e) => unravel_errors("Failed to build the site", e, true),
Err(e) => unravel_errors("Failed to build the site", &e, true),
};
},
_ => unreachable!(),


Loading…
Cancel
Save