From 9f1219005dba50d9e35ad00b3d49f4a3e8b32015 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 10 Aug 2022 21:37:48 +0200 Subject: [PATCH 1/2] fix the significant_drop_in_scrutinee clippy warning --- src/uu/factor/src/cli.rs | 4 ++-- src/uu/rm/src/rm.rs | 4 ++-- src/uu/wc/src/wc.rs | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/uu/factor/src/cli.rs b/src/uu/factor/src/cli.rs index 2410876d6..a8e02261c 100644 --- a/src/uu/factor/src/cli.rs +++ b/src/uu/factor/src/cli.rs @@ -61,8 +61,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } else { let stdin = stdin(); - - for line in stdin.lock().lines() { + let lines = stdin.lock().lines(); + for line in lines { for number in line.unwrap().split_whitespace() { if let Err(e) = print_factors_str(number, &mut w, &mut factors_buffer) { show_warning!("{}: {}", number.maybe_quote(), e); diff --git a/src/uu/rm/src/rm.rs b/src/uu/rm/src/rm.rs index 21ecb32d3..47e695d62 100644 --- a/src/uu/rm/src/rm.rs +++ b/src/uu/rm/src/rm.rs @@ -429,8 +429,8 @@ fn prompt(msg: &str) -> bool { let mut buf = Vec::new(); let stdin = stdin(); let mut stdin = stdin.lock(); - - match stdin.read_until(b'\n', &mut buf) { + let read = stdin.read_until(b'\n', &mut buf); + match read { Ok(x) if x > 0 => matches!(buf[0], b'y' | b'Y'), _ => false, } diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index 600f677bc..b904fc3fb 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -474,7 +474,8 @@ fn word_count_from_input(input: &Input, settings: &Settings) -> CountResult { Input::Stdin(_) => { let stdin = io::stdin(); let stdin_lock = stdin.lock(); - match word_count_from_reader(stdin_lock, settings) { + let count = word_count_from_reader(stdin_lock, settings); + match count { (total, Some(error)) => CountResult::Interrupted(total, error), (total, None) => CountResult::Success(total), } From a2e0296ef2fb7a1eaadb3c105bf55c4b9553cd56 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 10 Aug 2022 21:41:32 +0200 Subject: [PATCH 2/2] remove some unnecessary parentheses --- src/uu/mktemp/src/mktemp.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index 977590eae..561281c72 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -431,9 +431,9 @@ pub fn dry_exec(tmpdir: &str, prefix: &str, rand: usize, suffix: &str) -> UResul rand::thread_rng().fill(bytes); for byte in bytes.iter_mut() { *byte = match *byte % 62 { - v @ 0..=9 => (v + b'0'), - v @ 10..=35 => (v - 10 + b'a'), - v @ 36..=61 => (v - 36 + b'A'), + v @ 0..=9 => v + b'0', + v @ 10..=35 => v - 10 + b'a', + v @ 36..=61 => v - 36 + b'A', _ => unreachable!(), } }