From 112b8fb664fa528269e3dc9665952f035f8bb70a Mon Sep 17 00:00:00 2001 From: Mikhail Katychev Date: Fri, 26 Jul 2024 15:55:35 -0500 Subject: [PATCH] introduce Not term --- api/src/term/matcher/_any.rs | 11 +++++++++++ api/src/term/matcher/_graph_name_matcher.rs | 5 +---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/api/src/term/matcher/_any.rs b/api/src/term/matcher/_any.rs index e5968dda..062be0cd 100644 --- a/api/src/term/matcher/_any.rs +++ b/api/src/term/matcher/_any.rs @@ -11,3 +11,14 @@ impl TermMatcher for Any { true } } + +/// Matches on the inverse of the inner [`Term`] or [`GraphName`] +pub struct Not(pub M); + +impl TermMatcher for Not { + type Term = SimpleTerm<'static>; // not actually used + + fn matches(&self, term: &T2) -> bool { + !self.0.matches(term) + } +} diff --git a/api/src/term/matcher/_graph_name_matcher.rs b/api/src/term/matcher/_graph_name_matcher.rs index d08f508d..7eaf5a84 100644 --- a/api/src/term/matcher/_graph_name_matcher.rs +++ b/api/src/term/matcher/_graph_name_matcher.rs @@ -136,9 +136,6 @@ impl GraphNameMatcher for Any { } } -/// Matches on the inverse of the inner [`GraphNameMatcher`] -pub struct Not(pub M); - impl GraphNameMatcher for Not { type Term = SimpleTerm<'static>; // not actually used @@ -148,7 +145,7 @@ impl GraphNameMatcher for Not { } impl GraphNameMatcher for Option> { - type Term = SimpleTerm<'static>; // not actually used + type Term = SimpleTerm<'static>; fn matches(&self, graph_name: GraphName<&T2>) -> bool { graph_name_eq(self.as_ref(), graph_name.map(Term::as_simple))