sophia_api/term/matcher/
_term_matcher_gn.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use super::*;

/// Wrapper type returned by [`TermMatcher::gn`]
#[derive(Clone, Copy, Debug)]
pub struct TermMatcherGn<T>(pub(super) T);

impl<M> GraphNameMatcher for TermMatcherGn<M>
where
    M: TermMatcher,
{
    type Term = M::Term;

    fn matches<T2: Term + ?Sized>(&self, graph_name: GraphName<&T2>) -> bool {
        match graph_name {
            Some(term) => self.0.matches(term),
            None => false,
        }
    }
    fn constant(&self) -> Option<GraphName<&Self::Term>> {
        self.0.constant().map(Some)
    }
}

impl<'a, T: GraphNameMatcher + ?Sized> GraphNameMatcher for MatcherRef<'a, T> {
    type Term = T::Term;

    fn matches<T2: Term + ?Sized>(&self, graph_name: GraphName<&T2>) -> bool {
        self.0.matches(graph_name)
    }

    fn constant(&self) -> Option<GraphName<&Self::Term>> {
        self.0.constant()
    }
}