From 42f8a9af361f6f1e6f8e43b416208fdc97bf50c6 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 8 Jun 2026 22:26:20 +0200 Subject: [PATCH] find: fix clippy::needless_for_each --- src/find/matchers/time.rs | 16 ++++++---------- src/find/mod.rs | 8 ++++---- tests/test_find.rs | 12 ++++++------ 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/find/matchers/time.rs b/src/find/matchers/time.rs index 32e2b00..384c2ad 100644 --- a/src/find/matchers/time.rs +++ b/src/find/matchers/time.rs @@ -842,13 +842,11 @@ mod tests { // - find test_data/simple -cmin +1 // - find test_data/simple -mmin +1 // Means to find files accessed / modified more than 1 minute ago. - [ + for time_type in &[ FileTimeType::Accessed, FileTimeType::Changed, FileTimeType::Modified, - ] - .iter() - .for_each(|time_type| { + ] { let more_matcher = FileAgeRangeMatcher::new(*time_type, ComparableValue::MoreThan(1), true); assert!( @@ -863,7 +861,7 @@ mod tests { } ) ); - }); + } // less test // mocks: @@ -871,14 +869,12 @@ mod tests { // - find test_data/simple -cmin -1 // - find test_data/simple -mmin -1 // Means to find files accessed / modified less than 1 minute ago. - [ + for time_type in &[ FileTimeType::Accessed, #[cfg(unix)] FileTimeType::Changed, FileTimeType::Modified, - ] - .iter() - .for_each(|time_type| { + ] { let less_matcher = FileAgeRangeMatcher::new(*time_type, ComparableValue::LessThan(1), true); assert!( @@ -893,7 +889,7 @@ mod tests { } ) ); - }); + } // catch file error let _ = fs::remove_file(&*new_file.path().to_string_lossy()); diff --git a/src/find/mod.rs b/src/find/mod.rs index 984665e..df87609 100644 --- a/src/find/mod.rs +++ b/src/find/mod.rs @@ -1323,7 +1323,7 @@ mod tests { assert_eq!(rc, 1); // test empty user name - ["-user", "-nouser"].iter().for_each(|&arg| { + for &arg in &["-user", "-nouser"] { let deps = FakeDependencies::new(); let rc = find_main(&["find", "./test_data/simple/subdir", arg, ""], &deps); @@ -1333,7 +1333,7 @@ mod tests { let rc = find_main(&["find", "./test_data/simple/subdir", arg, " "], &deps); assert_eq!(rc, 1); - }); + } } #[test] @@ -1411,7 +1411,7 @@ mod tests { assert_eq!(rc, 1); // test empty user name and group name - ["-group", "-nogroup"].iter().for_each(|&arg| { + for &arg in &["-group", "-nogroup"] { let deps = FakeDependencies::new(); let rc = find_main(&["find", "./test_data/simple/subdir", arg, ""], &deps); @@ -1421,7 +1421,7 @@ mod tests { let rc = find_main(&["find", "./test_data/simple/subdir", arg, " "], &deps); assert_eq!(rc, 1); - }); + } } #[test] diff --git a/tests/test_find.rs b/tests/test_find.rs index 03c3722..5497a32 100644 --- a/tests/test_find.rs +++ b/tests/test_find.rs @@ -615,18 +615,18 @@ fn find_time() { "-ctime", "-mtime", ]; - tests.iter().for_each(|flag| { - args.iter().for_each(|arg| { + for flag in &tests { + for arg in &args { ucmd() .args(&["./test_data/simple", flag, arg]) .succeeds() .no_stderr(); - }); + } - exception_args.iter().for_each(|arg| { + for arg in &exception_args { ucmd().args(&[".", flag, arg]).fails().no_stdout(); - }); - }); + } + } } #[test]