Skip to main content

AsPattern

Trait AsPattern 

Source
pub trait AsPattern {
    type Ground: ?Sized;
    type Var: ?Sized;

    // Required method
    fn as_pattern(&self) -> Pattern<&Self::Ground, &Self::Var>;

    // Provided methods
    fn is_ground(&self) -> bool { ... }
    fn is_ground_and(&self, f: impl FnOnce(&Self::Ground) -> bool) -> bool { ... }
    fn is_var(&self) -> bool { ... }
    fn is_var_and(&self, f: impl FnOnce(&Self::Var) -> bool) -> bool { ... }
    fn is_ground_or(&self, f: impl FnOnce(&Self::Var) -> bool) -> bool { ... }
    fn is_var_or(&self, f: impl FnOnce(&Self::Ground) -> bool) -> bool { ... }
}
Expand description

Value that can be seen as a Pattern, either a ground value or a variable.

Implemented by Pattern itself. Resource types implementing this trait can be used with crate::find_bijection to find a blank node/variable-preserving bijection between two datasets.

Required Associated Types§

Source

type Ground: ?Sized

Ground value type.

Source

type Var: ?Sized

Variable type.

Required Methods§

Source

fn as_pattern(&self) -> Pattern<&Self::Ground, &Self::Var>

Borrows this value as a Pattern.

Provided Methods§

Source

fn is_ground(&self) -> bool

Checks if this value is a ground value (as opposed to a variable).

Source

fn is_ground_and(&self, f: impl FnOnce(&Self::Ground) -> bool) -> bool

Returns true if this value is a ground value satisfying the given predicate, and false if it is a variable.

Source

fn is_var(&self) -> bool

Checks if this value is a variable (as opposed to a ground value).

Source

fn is_var_and(&self, f: impl FnOnce(&Self::Var) -> bool) -> bool

Returns true if this value is a variable satisfying the given predicate, and false if it is a ground value.

Source

fn is_ground_or(&self, f: impl FnOnce(&Self::Var) -> bool) -> bool

Returns true if this value is a ground value, or if it is a variable satisfying the given predicate.

Source

fn is_var_or(&self, f: impl FnOnce(&Self::Ground) -> bool) -> bool

Returns true if this value is a variable, or if it is a ground value satisfying the given predicate.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl AsPattern for Term

Blank node identifiers act as the variable side of the Pattern ground/variable abstraction, and ground terms act as the ground side.

This lets lexical RDF data be used directly with rdf-types’ pattern matching and isomorphism-checking facilities (e.g. are_isomorphic and find_bijection), since blank node identifiers, like pattern variables, are existentially quantified and can be renamed without changing the meaning of the data.

Source§

impl<T, X> AsPattern for Pattern<T, X>

Source§

type Ground = T

Source§

type Var = X