Skip to main content

Pattern

Enum Pattern 

Source
pub enum Pattern<T, X> {
    Ground(T),
    Var(X),
}
Expand description

Resource or variable.

Used as a triple/quad component to represent either a fixed (Ground) resource, or a Variable that may be substituted for any resource.

Variants§

§

Ground(T)

Ground (fixed) resource.

§

Var(X)

Variable, matching any resource.

Implementations§

Source§

impl<T, X> Pattern<T, X>

Source

pub fn as_ref(&self) -> Pattern<&T, &X>

Borrows the ground value or variable of this pattern.

Source

pub fn as_deref(&self) -> Pattern<&T::Target, &X::Target>
where T: Deref, X: Deref,

Dereferences the ground value or variable of this pattern.

Source

pub fn is_ground(&self) -> bool

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

Source

pub fn is_ground_and(&self, f: impl FnOnce(&T) -> bool) -> bool

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

Source

pub fn is_var(&self) -> bool

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

Source

pub fn is_var_and(&self, f: impl FnOnce(&X) -> bool) -> bool

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

Source

pub fn is_ground_or(&self, f: impl FnOnce(&X) -> bool) -> bool

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

Mirrors Option::is_none_or, with Self::Ground playing the role of None.

Source

pub fn is_var_or(&self, f: impl FnOnce(&T) -> bool) -> bool

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

Mirrors Option::is_none_or, with Self::Var playing the role of None.

Source

pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Pattern<U, X>

Maps the ground value with the given function, leaving a variable untouched.

Source

pub fn map_var<Y>(self, f: impl FnOnce(X) -> Y) -> Pattern<T, Y>

Maps the variable with the given function, leaving a ground value untouched.

Trait Implementations§

Source§

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

Source§

type Ground = T

Ground value type.
Source§

type Var = X

Variable type.
Source§

fn as_pattern(&self) -> Pattern<&T, &X>

Borrows this value as a Pattern.
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.
Source§

impl<T: Clone, X: Clone> Clone for Pattern<T, X>

Source§

fn clone(&self) -> Pattern<T, X>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Copy, X: Copy> Copy for Pattern<T, X>

Source§

impl<T: Debug, X: Debug> Debug for Pattern<T, X>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Eq, X: Eq> Eq for Pattern<T, X>

Source§

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

Source§

fn from(value: T) -> Self

Creates a ground pattern from a resource.

Source§

impl<T: Hash, X: Hash> Hash for Pattern<T, X>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T, X> IntoOwned for Pattern<T, X>
where T: IntoOwned, X: IntoOwned,

Source§

type Owned = Pattern<<T as IntoOwned>::Owned, <X as IntoOwned>::Owned>

The fully owned type produced by into_owned.
Source§

fn into_owned(self) -> Self::Owned

Converts self into a fully owned value, consuming it. Read more
Source§

impl<T: Ord, X: Ord> Ord for Pattern<T, X>

Source§

fn cmp(&self, other: &Pattern<T, X>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq, X: PartialEq> PartialEq for Pattern<T, X>

Source§

fn eq(&self, other: &Pattern<T, X>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd, X: PartialOrd> PartialOrd for Pattern<T, X>

Source§

fn partial_cmp(&self, other: &Pattern<T, X>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: PartialEq, X: PartialEq> StructuralPartialEq for Pattern<T, X>

Auto Trait Implementations§

§

impl<T, X> Freeze for Pattern<T, X>
where T: Freeze, X: Freeze,

§

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

§

impl<T, X> Send for Pattern<T, X>
where T: Send, X: Send,

§

impl<T, X> Sync for Pattern<T, X>
where T: Sync, X: Sync,

§

impl<T, X> Unpin for Pattern<T, X>
where T: Unpin, X: Unpin,

§

impl<T, X> UnsafeUnpin for Pattern<T, X>
where T: UnsafeUnpin, X: UnsafeUnpin,

§

impl<T, X> UnwindSafe for Pattern<T, X>
where T: UnwindSafe, X: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.