From 55021afb696f6ecb87d1e3dd43aba3d7b80be670 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 3 Apr 2025 15:13:23 +0200 Subject: [PATCH] clippy: fix errors from double_ended_iterator_last lint --- src/find/matchers/entry.rs | 2 +- src/xargs/mod.rs | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/find/matchers/entry.rs b/src/find/matchers/entry.rs index 239b0e7..ab4b2b4 100644 --- a/src/find/matchers/entry.rs +++ b/src/find/matchers/entry.rs @@ -278,7 +278,7 @@ impl WalkEntry { Entry::Explicit(path, _) => { // Path::file_name() only works if the last component is normal path.components() - .last() + .next_back() .map(|c| c.as_os_str()) .unwrap_or_else(|| path.as_os_str()) } diff --git a/src/xargs/mod.rs b/src/xargs/mod.rs index 7993a5b..44c9a19 100644 --- a/src/xargs/mod.rs +++ b/src/xargs/mod.rs @@ -799,11 +799,13 @@ fn normalize_options<'a>( ); let lines_index = matches .indices_of(options::MAX_LINES) - .and_then(|v| v.last()); - let args_index = matches.indices_of(options::MAX_ARGS).and_then(|v| v.last()); + .and_then(|mut v| v.next_back()); + let args_index = matches + .indices_of(options::MAX_ARGS) + .and_then(|mut v| v.next_back()); let replace_index = [options::REPLACE, options::REPLACE_I] .iter() - .flat_map(|o| matches.indices_of(o).and_then(|v| v.last())) + .flat_map(|o| matches.indices_of(o).and_then(|mut v| v.next_back())) .max(); if lines_index > args_index && lines_index > replace_index { (None, options.max_lines, &None) @@ -817,8 +819,8 @@ fn normalize_options<'a>( let delimiter = match (options.delimiter, options.null) { (Some(delimiter), true) => { - if matches.indices_of(options::NULL).unwrap().last() - > matches.indices_of(options::DELIMITER).unwrap().last() + if matches.indices_of(options::NULL).unwrap().next_back() + > matches.indices_of(options::DELIMITER).unwrap().next_back() { Some(b'\0') } else {