sophia_api::term::matcher

Trait TermMatcher

Source
pub trait TermMatcher {
    type Term: Term + ?Sized;

    // Required method
    fn matches<T2: Term + ?Sized>(&self, term: &T2) -> bool;

    // Provided methods
    fn constant(&self) -> Option<&Self::Term> { ... }
    fn gn(self) -> TermMatcherGn<Self>
       where Self: Sized { ... }
    fn matcher_ref(&self) -> MatcherRef<'_, Self> { ... }
}
Expand description

Generic trait for matching Terms.

Required Associated Types§

Source

type Term: Term + ?Sized

The type of term that this TermMatcher contains

Required Methods§

Source

fn matches<T2: Term + ?Sized>(&self, term: &T2) -> bool

Check whether this matcher matches t.

Provided Methods§

Source

fn constant(&self) -> Option<&Self::Term>

Return None, unless this matcher can only match a single term, in which case this method may return that term.

This method is provided for optimization purposes, so implementing it is optional.

Source

fn gn(self) -> TermMatcherGn<Self>
where Self: Sized,

Converts this TermMatcher into a GraphNameMatcher

If you only want to borrow this matcher as a GraphNameMatcher, call gn on the result of matcher_ref.

Source

fn matcher_ref(&self) -> MatcherRef<'_, Self>

Return a TermMatcher that is actually just a reference to this one.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<S, P, O> TermMatcher for (S, P, O)

Matches only embedded triple whose components match the corresponding matchers.

Source§

type Term = <S as TermMatcher>::Term

Source§

fn matches<T2: Term + ?Sized>(&self, term: &T2) -> bool

Source§

impl<T> TermMatcher for &[T]
where T: Term,

Matches any of the terms in the slice.

Source§

type Term = T

Source§

fn matches<T2: Term + ?Sized>(&self, term: &T2) -> bool

Source§

fn constant(&self) -> Option<&Self::Term>

Source§

impl<T> TermMatcher for Option<T>
where T: Term,

Matches the wrapped term if any, otherwise matches nothing.

Source§

type Term = T

Source§

fn matches<T2: Term + ?Sized>(&self, term: &T2) -> bool

Source§

fn constant(&self) -> Option<&Self::Term>

Source§

impl<T, const N: usize> TermMatcher for [T; N]
where T: Term,

Matches any of the terms in the array.

Source§

type Term = T

Source§

fn matches<T2: Term + ?Sized>(&self, term: &T2) -> bool

Source§

fn constant(&self) -> Option<&Self::Term>

Implementors§

Source§

impl TermMatcher for TermKind

Matches any term if the given kind

Source§

type Term = SimpleTerm<'static>

Source§

impl TermMatcher for Any

Source§

type Term = SimpleTerm<'static>

Source§

impl<'a, T: TermMatcher + ?Sized> TermMatcher for MatcherRef<'a, T>

Source§

impl<F> TermMatcher for F
where F: Fn(SimpleTerm<'_>) -> bool + ?Sized,

Matches any term satisfying the function.

Source§

type Term = SimpleTerm<'static>

Source§

impl<T: Borrow<str>> TermMatcher for DatatypeMatcher<T>

Source§

type Term = SimpleTerm<'static>

Source§

impl<T: Borrow<str>> TermMatcher for LanguageTagMatcher<T>

Source§

type Term = SimpleTerm<'static>