sophia_api/term/matcher/
_matcher_ref.rs

1use super::*;
2
3/// Result type of [`TermMatcher::matcher_ref`] and [`GraphNameMatcher::matcher_ref`].
4#[derive(Debug)]
5pub struct MatcherRef<'a, T: ?Sized>(pub(super) &'a T);
6
7impl<'a, T> Clone for MatcherRef<'a, T> {
8    fn clone(&self) -> Self {
9        *self
10    }
11}
12impl<'a, T> Copy for MatcherRef<'a, T> {}
13
14impl<'a, T: TermMatcher + ?Sized> TermMatcher for MatcherRef<'a, T> {
15    type Term = T::Term;
16
17    fn matches<T2: Term + ?Sized>(&self, term: &T2) -> bool {
18        self.0.matches(term)
19    }
20
21    fn constant(&self) -> Option<&Self::Term> {
22        self.0.constant()
23    }
24}