From b522f2b9b53fcca95f32d325d476111798c381a0 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Thu, 29 May 2025 13:53:27 +0200 Subject: [PATCH] uucore: Use next_back on PathBuf's DoubleEndedIterator As recommended by clippy, last() needlessly goes through the whole path while next_back() is available. --- src/uucore/src/lib/features/proc_info.rs | 2 +- src/uucore/src/lib/features/tty.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uucore/src/lib/features/proc_info.rs b/src/uucore/src/lib/features/proc_info.rs index 7ea54a85a..3f5334d10 100644 --- a/src/uucore/src/lib/features/proc_info.rs +++ b/src/uucore/src/lib/features/proc_info.rs @@ -164,7 +164,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/uucore/src/lib/features/tty.rs b/src/uucore/src/lib/features/tty.rs index 6854ba164..221ee442d 100644 --- a/src/uucore/src/lib/features/tty.rs +++ b/src/uucore/src/lib/features/tty.rs @@ -73,7 +73,7 @@ impl TryFrom for Teletype { let f = |prefix: &str| { value .iter() - .last()? + .next_back()? .to_str()? .strip_prefix(prefix)? .parse::()