From fe53af064b5c27c996c326fc84436ef9a38af664 Mon Sep 17 00:00:00 2001 From: Alexandru Macovei Date: Sat, 26 Jan 2019 03:13:16 +0200 Subject: [PATCH] fix most clippy lints --- src/app.rs | 2 +- src/internal/filter/size.rs | 8 ++++---- src/main.rs | 2 +- src/output.rs | 6 +++--- src/walk.rs | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/app.rs b/src/app.rs index ef34814..950ec1e 100644 --- a/src/app.rs +++ b/src/app.rs @@ -219,7 +219,7 @@ pub fn build_app() -> App<'static, 'static> { ) } -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] fn usage() -> HashMap<&'static str, Help> { let mut h = HashMap::new(); doc!(h, "hidden" diff --git a/src/internal/filter/size.rs b/src/internal/filter/size.rs index b534f8d..fafd4b5 100644 --- a/src/internal/filter/size.rs +++ b/src/internal/filter/size.rs @@ -24,7 +24,7 @@ const GIBI: u64 = MEBI * 1024; const TEBI: u64 = GIBI * 1024; impl SizeFilter { - pub fn from_string<'a>(s: &str) -> Option { + pub fn from_string(s: &str) -> Option { if !SIZE_CAPTURES.is_match(s) { return None; } @@ -56,9 +56,9 @@ impl SizeFilter { } pub fn is_within(&self, size: u64) -> bool { - match self { - &SizeFilter::Max(limit) => size <= limit, - &SizeFilter::Min(limit) => size >= limit, + match *self { + SizeFilter::Max(limit) => size <= limit, + SizeFilter::Min(limit) => size >= limit, } } } diff --git a/src/main.rs b/src/main.rs index 571bdc6..8fad65b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,7 +49,7 @@ fn main() { // Get one or more root directories to search. let mut dir_vec: Vec<_> = match matches .values_of("path") - .or(matches.values_of("search-path")) + .or_else(|| matches.values_of("search-path")) { Some(paths) => paths .map(|path| { diff --git a/src/output.rs b/src/output.rs index ed62f3c..a5d0c1e 100644 --- a/src/output.rs +++ b/src/output.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use ansi_term; /// Remove the `./` prefix from a path. -fn strip_current_dir<'a>(pathbuf: &'a PathBuf) -> &'a Path { +fn strip_current_dir(pathbuf: &PathBuf) -> &Path { let mut iter = pathbuf.components(); let mut iter_next = iter.clone(); if iter_next.next() == Some(Component::CurDir) { @@ -70,7 +70,7 @@ fn print_entry_colorized( write!(stdout, "{}", style.paint(component.to_string_lossy()))?; if wants_to_quit.load(Ordering::Relaxed) { - write!(stdout, "\n")?; + writeln!(stdout)?; process::exit(ExitCode::KilledBySigint.into()); } } @@ -78,7 +78,7 @@ fn print_entry_colorized( if config.null_separator { write!(stdout, "\0") } else { - writeln!(stdout, "") + writeln!(stdout) } } diff --git a/src/walk.rs b/src/walk.rs index 3a735f6..f085bda 100644 --- a/src/walk.rs +++ b/src/walk.rs @@ -304,7 +304,7 @@ fn spawn_senders( // Filter out unwanted extensions. if let Some(ref exts_regex) = config.extensions { - if let Some(path_str) = entry_path.file_name().map_or(None, |s| s.to_str()) { + if let Some(path_str) = entry_path.file_name().and_then(|s| s.to_str()) { if !exts_regex.is_match(path_str) { return ignore::WalkState::Continue; } @@ -314,7 +314,7 @@ fn spawn_senders( } // Filter out unwanted sizes if it is a file and we have been given size constraints. - if config.size_constraints.len() > 0 { + if !config.size_constraints.is_empty() { if entry_path.is_file() { if let Ok(metadata) = entry_path.metadata() { let file_size = metadata.len();