clippy: fix errors from double_ended_iterator_last

lint
This commit is contained in:
Daniel Hofstetter
2025-04-04 09:21:12 +02:00
committed by Sylvestre Ledru
parent 013be1b093
commit 55021afb69
2 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -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())
}
+7 -5
View File
@@ -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 {