Skip to content

Commit

Permalink
matchers: simplify DifferenceMatcher slightly
Browse files Browse the repository at this point in the history
The new `Visit::Nothing` variant lets us more easily restructure
`DifferenceMatcher::visit()` to make it handle the case of not
removing anything. I think this makes the code a little clearer.
  • Loading branch information
martinvonz committed Jun 10, 2022
1 parent 014de54 commit 932ce9b
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions lib/src/matchers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,12 @@ impl Matcher for DifferenceMatcher<'_> {
fn visit(&self, dir: &RepoPath) -> Visit {
match self.unwanted.visit(dir) {
Visit::AllRecursively => Visit::Nothing,
unwanted_visit => match self.wanted.visit(dir) {
Visit::AllRecursively => {
if unwanted_visit == Visit::Nothing {
Visit::AllRecursively
} else {
Visit::Specific {
dirs: VisitDirs::All,
files: VisitFiles::All,
}
}
}
Visit::Nothing => self.wanted.visit(dir),
Visit::Specific { .. } => match self.wanted.visit(dir) {
Visit::AllRecursively => Visit::Specific {
dirs: VisitDirs::All,
files: VisitFiles::All,
},
wanted_visit => wanted_visit,
},
}
Expand Down

0 comments on commit 932ce9b

Please sign in to comment.