diff --git a/bin/src/dirs.rs b/bin/src/dirs.rs index bccc555..13b66d7 100644 --- a/bin/src/dirs.rs +++ b/bin/src/dirs.rs @@ -47,27 +47,26 @@ impl Iterator for Walker { fn next(&mut self) -> Option { self.files.pop().or_else(|| { while let Some(dir) = self.dirs.pop() { - if dir.is_dir() { - if let Match::None | Match::Whitelist(_) = self.ignore.matched(&dir, true) { - let mut found = false; - for entry in fs::read_dir(&dir).ok()? { - let entry = entry.ok()?; - let path = entry.path(); - if path.is_dir() { - self.dirs.push(path); - } else if path.is_file() { - if let Match::None | Match::Whitelist(_) = - self.ignore.matched(&path, false) - { - found = true; - self.files.push(path); - } - } - } - if found { - break; + if dir.is_dir() + && let Match::None | Match::Whitelist(_) = self.ignore.matched(&dir, true) + { + let mut found = false; + for entry in fs::read_dir(&dir).ok()? { + let entry = entry.ok()?; + let path = entry.path(); + if path.is_dir() { + self.dirs.push(path); + } else if path.is_file() + && let Match::None | Match::Whitelist(_) = + self.ignore.matched(&path, false) + { + found = true; + self.files.push(path); } } + if found { + break; + } } } self.files.pop()