From 27caa337296398d115f8779e08606897d8d9ad5e Mon Sep 17 00:00:00 2001 From: sharkdp Date: Thu, 27 Sep 2018 23:01:38 +0200 Subject: [PATCH] cargo fmt --- src/app.rs | 45 +++++++++++++++++++++++++++++--------------- src/fshelper/mod.rs | 3 ++- src/main.rs | 15 ++++++++++----- src/walk.rs | 3 ++- tests/testenv/mod.rs | 6 ++++-- tests/tests.rs | 3 ++- 6 files changed, 50 insertions(+), 25 deletions(-) diff --git a/src/app.rs b/src/app.rs index deab2f3..55ca402 100644 --- a/src/app.rs +++ b/src/app.rs @@ -50,22 +50,26 @@ pub fn build_app() -> App<'static, 'static> { .short("u") .multiple(true) .hidden(true), - ).arg( + ) + .arg( arg("case-sensitive") .long("case-sensitive") .short("s") .overrides_with("ignore-case"), - ).arg( + ) + .arg( arg("ignore-case") .long("ignore-case") .short("i") .overrides_with("case-sensitive"), - ).arg( + ) + .arg( arg("fixed-strings") .long("fixed-strings") .short("F") .alias("literal"), - ).arg(arg("absolute-path").long("absolute-path").short("a")) + ) + .arg(arg("absolute-path").long("absolute-path").short("a")) .arg(arg("follow").long("follow").short("L").alias("dereference")) .arg(arg("full-path").long("full-path").short("p")) .arg(arg("null_separator").long("print0").short("0")) @@ -76,7 +80,8 @@ pub fn build_app() -> App<'static, 'static> { .long("maxdepth") .hidden(true) .takes_value(true), - ).arg( + ) + .arg( arg("file-type") .long("type") .short("t") @@ -95,8 +100,10 @@ pub fn build_app() -> App<'static, 'static> { "executable", "e", "empty", - ]).hide_possible_values(true), - ).arg( + ]) + .hide_possible_values(true), + ) + .arg( arg("extension") .long("extension") .short("e") @@ -104,7 +111,8 @@ pub fn build_app() -> App<'static, 'static> { .number_of_values(1) .takes_value(true) .value_name("ext"), - ).arg( + ) + .arg( arg("exec") .long("exec") .short("x") @@ -112,7 +120,8 @@ pub fn build_app() -> App<'static, 'static> { .allow_hyphen_values(true) .value_terminator(";") .value_name("cmd"), - ).arg( + ) + .arg( arg("exclude") .long("exclude") .short("E") @@ -120,14 +129,16 @@ pub fn build_app() -> App<'static, 'static> { .value_name("pattern") .number_of_values(1) .multiple(true), - ).arg( + ) + .arg( arg("ignore-file") .long("ignore-file") .takes_value(true) .value_name("path") .number_of_values(1) .multiple(true), - ).arg( + ) + .arg( arg("color") .long("color") .short("c") @@ -135,13 +146,15 @@ pub fn build_app() -> App<'static, 'static> { .value_name("when") .possible_values(&["never", "auto", "always"]) .hide_possible_values(true), - ).arg( + ) + .arg( arg("threads") .long("threads") .short("j") .takes_value(true) .value_name("num"), - ).arg( + ) + .arg( arg("size") .long("size") .short("S") @@ -149,12 +162,14 @@ pub fn build_app() -> App<'static, 'static> { .number_of_values(1) .allow_hyphen_values(true) .multiple(true), - ).arg( + ) + .arg( arg("max-buffer-time") .long("max-buffer-time") .takes_value(true) .hidden(true), - ).arg(arg("pattern")) + ) + .arg(arg("pattern")) .arg(arg("path").multiple(true)) } diff --git a/src/fshelper/mod.rs b/src/fshelper/mod.rs index 33f6fd7..10db0f2 100644 --- a/src/fshelper/mod.rs +++ b/src/fshelper/mod.rs @@ -33,7 +33,8 @@ pub fn absolute_path(path: &Path) -> io::Result { .as_path() .to_string_lossy() .trim_left_matches(r"\\?\"), - ).to_path_buf(); + ) + .to_path_buf(); Ok(path_buf) } diff --git a/src/main.rs b/src/main.rs index 1835f32..defcde5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,7 +67,8 @@ fn main() { )); } path_buffer - }).collect::>(), + }) + .collect::>(), None => vec![current_dir.to_path_buf()], }; @@ -79,7 +80,8 @@ fn main() { .canonicalize() .and_then(|pb| fshelper::absolute_path(pb.as_path())) .unwrap() - }).collect(); + }) + .collect(); } // Detect if the user accidentally supplied a path instead of a search pattern @@ -141,8 +143,10 @@ fn main() { return f; } error(&format!("Error: {} is not a valid size constraint.", sf)); - }).collect() - }).unwrap_or_else(|| vec![]); + }) + .collect() + }) + .unwrap_or_else(|| vec![]); let config = FdOptions { case_sensitive, @@ -233,7 +237,8 @@ fn main() { "{}\nHint: You can use the '--fixed-strings' option to search for a \ literal string instead of a regular expression", err.description() - ).as_str(), + ) + .as_str(), ), } } diff --git a/src/walk.rs b/src/walk.rs index 33caaa9..689f765 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -106,7 +106,8 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc, config: Arc) { let wq = Arc::clone(&receiver_wtq); ctrlc::set_handler(move || { wq.store(true, Ordering::Relaxed); - }).unwrap(); + }) + .unwrap(); } // Spawn the thread that receives all results through the channel. diff --git a/tests/testenv/mod.rs b/tests/testenv/mod.rs index 7cea96b..1d535f8 100644 --- a/tests/testenv/mod.rs +++ b/tests/testenv/mod.rs @@ -106,7 +106,8 @@ fn format_output_error(args: &[&str], expected: &str, actual: &str) -> String { diff::Result::Left(l) => format!("-{}", l), diff::Result::Both(l, _) => format!(" {}", l), diff::Result::Right(r) => format!("+{}", r), - }).collect::>() + }) + .collect::>() .join("\n"); format!( @@ -128,7 +129,8 @@ fn normalize_output(s: &str, trim_left: bool) -> String { .map(|line| { let line = if trim_left { line.trim_left() } else { line }; line.replace('/', &std::path::MAIN_SEPARATOR.to_string()) - }).collect::>(); + }) + .collect::>(); lines.sort_by_key(|s| s.clone()); diff --git a/tests/tests.rs b/tests/tests.rs index cc719b2..137bd2b 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1028,7 +1028,8 @@ fn test_invalid_utf8() { fs::File::create( te.test_root() .join(OsStr::from_bytes(b"test1/test_\xFEinvalid.txt")), - ).unwrap(); + ) + .unwrap(); te.assert_output(&["", "test1/"], "test1/test_�invalid.txt");