-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement overriding Combine not operator
- Loading branch information
1 parent
86c39f2
commit a0d4abd
Showing
6 changed files
with
70 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use super::Matcher; | ||
|
||
#[derive(Clone)] | ||
enum CombineUnaryMatcherKind { | ||
Not, | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct UnaryCombineMatcher<T> { | ||
matcher: Box<dyn Matcher<T>>, | ||
kind: CombineUnaryMatcherKind, | ||
} | ||
|
||
impl<T: Clone> UnaryCombineMatcher<T> { | ||
pub fn not(matcher: Box<dyn Matcher<T>>) -> Self { | ||
UnaryCombineMatcher { | ||
matcher, | ||
kind: CombineUnaryMatcherKind::Not, | ||
} | ||
} | ||
} | ||
|
||
impl<T: Clone> Matcher<T> for UnaryCombineMatcher<T> { | ||
fn is_match(&self, node: &T) -> bool { | ||
match &self.kind { | ||
CombineUnaryMatcherKind::Not => !self.matcher.is_match(node), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters