From eded6058393b158c2668efbed6cb83e336780e49 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 3 Apr 2025 16:54:05 +0200 Subject: [PATCH 1/3] clippy: fix warnings from doc_overindented_list_items lint --- tests/common/util.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/common/util.rs b/tests/common/util.rs index cfd914f..a269d87 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -1186,9 +1186,9 @@ impl TestScenario { /// A `UCommand` is a builder wrapping an individual Command that provides several additional features: /// 1. it has convenience functions that are more ergonomic to use for piping in stdin, spawning the command -/// and asserting on the results. +/// and asserting on the results. /// 2. it tracks arguments provided so that in test cases which may provide variations of an arg in loops -/// the test failure can display the exact call which preceded an assertion failure. +/// the test failure can display the exact call which preceded an assertion failure. /// 3. it provides convenience construction methods to set the Command uutils utility and temporary directory. /// /// Per default `UCommand` runs a command given as an argument in a shell, platform independently. From 1d9347ecd29bfe14a2e67ac9f7470e22058876d6 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 3 Apr 2025 16:58:13 +0200 Subject: [PATCH 2/3] clippy: fix warning from manual_repeat_n lint --- src/uu/top/src/top.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/top/src/top.rs b/src/uu/top/src/top.rs index 885ebd1..a182000 100644 --- a/src/uu/top/src/top.rs +++ b/src/uu/top/src/top.rs @@ -154,7 +154,7 @@ where input.chars().take(width).collect() } else { let mut result = String::from(&input); - result.extend(std::iter::repeat(' ').take(width - input.len())); + result.extend(std::iter::repeat_n(' ', width - input.len())); result } } From c597cc699bde096bc3515c92e939dde69be1341b Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 3 Apr 2025 17:02:52 +0200 Subject: [PATCH 3/3] clippy: fix warnings from double_ended_iterator_last lint --- src/uu/pgrep/src/process.rs | 4 ++-- src/uu/snice/src/snice.rs | 2 +- src/uu/top/src/picker.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/uu/pgrep/src/process.rs b/src/uu/pgrep/src/process.rs index 50521b2..91b8a3b 100644 --- a/src/uu/pgrep/src/process.rs +++ b/src/uu/pgrep/src/process.rs @@ -79,7 +79,7 @@ impl TryFrom for Teletype { let f = |prefix: &str| { value .iter() - .last()? + .next_back()? .to_str()? .strip_prefix(prefix)? .parse::() @@ -229,7 +229,7 @@ impl ProcessInformation { let pid = { value .iter() - .last() + .next_back() .ok_or(io::ErrorKind::Other)? .to_str() .ok_or(io::ErrorKind::InvalidData)? diff --git a/src/uu/snice/src/snice.rs b/src/uu/snice/src/snice.rs index 8a6af84..f9a8e6b 100644 --- a/src/uu/snice/src/snice.rs +++ b/src/uu/snice/src/snice.rs @@ -213,7 +213,7 @@ fn construct_verbose_result(pids: &[u32], action_results: &[Option let mut cmd = process .exe() - .and_then(|it| it.iter().last()) + .and_then(|it| it.iter().next_back()) .unwrap_or("?".as_ref()); let cmd = cmd.to_str().unwrap(); diff --git a/src/uu/top/src/picker.rs b/src/uu/top/src/picker.rs index f103e9b..beae924 100644 --- a/src/uu/top/src/picker.rs +++ b/src/uu/top/src/picker.rs @@ -193,7 +193,7 @@ fn command(pid: u32) -> String { }; proc.exe() - .and_then(|it| it.iter().last()) + .and_then(|it| it.iter().next_back()) .map(|it| it.to_str().unwrap()) .unwrap_or(&f(proc.cmd())) .into()