find: fix clippy::needless_for_each

This commit is contained in:
Sylvestre Ledru
2026-06-08 22:48:45 +02:00
parent 664a9c23e6
commit 42f8a9af36
3 changed files with 16 additions and 20 deletions
+6 -10
View File
@@ -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());
+4 -4
View File
@@ -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]
+6 -6
View File
@@ -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]