Skip to content

Commit d3870d0

Browse files
oech3cakebaker
authored andcommitted
rmdir: remove collapsible_if
1 parent e006be0 commit d3870d0

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

src/uu/rmdir/src/rmdir.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,22 +152,14 @@ const PERHAPS_EMPTY_CODES: &[i32] = &[
152152
];
153153

154154
fn dir_not_empty(error: &io::Error, path: &Path) -> bool {
155-
if let Some(code) = error.raw_os_error() {
156-
if NOT_EMPTY_CODES.contains(&code) {
157-
return true;
158-
}
155+
error.raw_os_error().is_some_and(|code| {
156+
NOT_EMPTY_CODES.contains(&code)
159157
// If --ignore-fail-on-non-empty is used then we want to ignore all errors
160158
// for non-empty directories, even if the error was e.g. because there's
161159
// no permission. So we do an additional check.
162-
if PERHAPS_EMPTY_CODES.contains(&code) {
163-
if let Ok(mut iterator) = read_dir(path) {
164-
if iterator.next().is_some() {
165-
return true;
166-
}
167-
}
168-
}
169-
}
170-
false
160+
|| PERHAPS_EMPTY_CODES.contains(&code)
161+
&& read_dir(path).is_ok_and(|mut iter| iter.next().is_some())
162+
})
171163
}
172164

173165
#[derive(Clone, Copy, Debug)]

0 commit comments

Comments
 (0)