File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -152,22 +152,14 @@ const PERHAPS_EMPTY_CODES: &[i32] = &[
152152] ;
153153
154154fn 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 ) ]
You can’t perform that action at this time.
0 commit comments