Skip to content

Commit

Permalink
introduce Not term
Browse files Browse the repository at this point in the history
  • Loading branch information
mkatychev committed Jul 26, 2024
1 parent 7b36941 commit 7dd61a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 11 additions & 0 deletions api/src/term/matcher/_any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ impl TermMatcher for Any {
true
}
}

/// Matches on the inverse of the inner [`Term`] or [`GraphName`]
pub struct Not<M>(pub M);

impl<M: TermMatcher> TermMatcher for Not<M> {
type Term = SimpleTerm<'static>; // not actually used

fn matches<T2: Term + ?Sized>(&self, term: &T2) -> bool {
!self.0.matches(term)
}
}
5 changes: 1 addition & 4 deletions api/src/term/matcher/_graph_name_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ impl GraphNameMatcher for Any {
}
}

/// Matches on the inverse of the inner [`GraphNameMatcher`]
pub struct Not<M>(pub M);

impl<M: GraphNameMatcher> GraphNameMatcher for Not<M> {
type Term = SimpleTerm<'static>; // not actually used

Expand All @@ -148,7 +145,7 @@ impl<M: GraphNameMatcher> GraphNameMatcher for Not<M> {
}

impl GraphNameMatcher for Option<SimpleTerm<'static>> {
type Term = SimpleTerm<'static>; // not actually used
type Term = SimpleTerm<'static>;

fn matches<T2: Term + ?Sized>(&self, graph_name: GraphName<&T2>) -> bool {
graph_name_eq(self.as_ref(), graph_name.map(Term::as_simple))
Expand Down

0 comments on commit 7dd61a5

Please sign in to comment.