From fc51f8128a5ee6080611c274ebb49361e0d5d503 Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 27 Apr 2021 20:26:01 +1000 Subject: [PATCH] rustfmt --- src/main.rs | 14 ++++++++++++-- src/parameters.rs | 12 +++++------- src/tests/mod.rs | 12 ++++++------ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/main.rs b/src/main.rs index 22282c0..0fd2bcb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,7 +88,12 @@ fn main() { debug!("Checking files regardless of extensions"); } - let entries = scan_directory(&args.dirs, extensions.as_ref(), excludes.as_ref(), &args.get_scan_opts()); + let entries = scan_directory( + &args.dirs, + extensions.as_ref(), + excludes.as_ref(), + &args.get_scan_opts(), + ); if entries.is_none() { // no need to log anything for fatal errors - fif will already have printed something obvious like @@ -285,7 +290,12 @@ fn scan_from_walkdir(entries: &[DirEntry]) -> Vec> { /// Scans a given directory with [`WalkDir`], filters with [`wanted_file`], checks for errors, and returns a vector of /// [DirEntry]s. -fn scan_directory(dirs: &Path, exts: Option<&Vec<&str>>, exclude: Option<&Vec<&str>>, scan_opts: &ScanOpts) -> Option> { +fn scan_directory( + dirs: &Path, + exts: Option<&Vec<&str>>, + exclude: Option<&Vec<&str>>, + scan_opts: &ScanOpts, +) -> Option> { let stepper = WalkDir::new(dirs).follow_links(scan_opts.follow_symlinks).into_iter(); let mut probably_fatal_error = false; let entries: Vec = stepper diff --git a/src/parameters.rs b/src/parameters.rs index 57133aa..d3d208e 100644 --- a/src/parameters.rs +++ b/src/parameters.rs @@ -52,12 +52,7 @@ pub struct Parameters { /// Don't scan files with these extensions (comma-separated list). /// This option takes preference over files specified with -e or -E. - #[clap( - short = 'x', - long, - use_delimiter = true, - require_delimiter = true, - )] + #[clap(short = 'x', long, use_delimiter = true, require_delimiter = true)] pub exclude: Option>, /// Don't skip hidden files and directories. @@ -136,7 +131,10 @@ impl Parameters { } pub fn excluded_extensions(&self) -> Option> { - self.exclude.as_ref().map(|exclude| exclude.iter().map(|ext| ext.as_str()).collect()) + self + .exclude + .as_ref() + .map(|exclude| exclude.iter().map(|ext| ext.as_str()).collect()) } pub const fn get_scan_opts(&self) -> ScanOpts { diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 8099c59..f831d9d 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -174,10 +174,11 @@ fn argument_parsing() { let args: Parameters = Parameters::parse_from(vec!["fif", "-f", "-E", "images"]); // check if "jpg" is in the list of extensions to be scanned - assert!(args - .extensions() - .expect("args.extensions() should be Some(_)!") - .contains(&"jpg"), + assert!( + args + .extensions() + .expect("args.extensions() should be Some(_)!") + .contains(&"jpg"), "args.extensions() should contain the `images` set!" ); @@ -205,7 +206,7 @@ fn argument_parsing() { #[test] /// Ensure exclude overrides `-e` and `-E`. fn exclude_overrides() { - use crate::parameters::{Parameters}; + use crate::parameters::Parameters; use clap::Clap; // pass `-E images`, which includes many image extensions, and `-x jpg,png`, which should remove "jpg" and "png" from @@ -231,7 +232,6 @@ fn exclude_overrides() { assert!(extensions.contains(&"jkl")); } - #[test] /// Ensure that badly formed command line arguments are rejected. fn rejects_bad_args() {