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§
Implementations§
Source§impl<T, X> Pattern<T, X>
impl<T, X> Pattern<T, X>
Sourcepub fn as_deref(&self) -> Pattern<&<T as Deref>::Target, &<X as Deref>::Target>
pub fn as_deref(&self) -> Pattern<&<T as Deref>::Target, &<X as Deref>::Target>
Dereferences the ground value or variable of this pattern.
Sourcepub fn is_ground(&self) -> bool
pub fn is_ground(&self) -> bool
Checks if this pattern is a ground value (as opposed to a variable).
Sourcepub fn is_ground_and(&self, f: impl FnOnce(&T) -> bool) -> bool
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.
Sourcepub fn is_var(&self) -> bool
pub fn is_var(&self) -> bool
Checks if this pattern is a variable (as opposed to a ground value).
Sourcepub fn is_var_and(&self, f: impl FnOnce(&X) -> bool) -> bool
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.
Sourcepub fn is_ground_or(&self, f: impl FnOnce(&X) -> bool) -> bool
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.
Sourcepub fn is_var_or(&self, f: impl FnOnce(&T) -> bool) -> bool
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.
Trait Implementations§
Source§impl<T, X> AsPattern for Pattern<T, X>
impl<T, X> AsPattern for Pattern<T, X>
Source§fn is_ground(&self) -> bool
fn is_ground(&self) -> bool
Source§fn is_ground_and(&self, f: impl FnOnce(&Self::Ground) -> bool) -> bool
fn is_ground_and(&self, f: impl FnOnce(&Self::Ground) -> bool) -> bool
true if this value is a ground value satisfying the given
predicate, and false if it is a variable.Source§fn is_var_and(&self, f: impl FnOnce(&Self::Var) -> bool) -> bool
fn is_var_and(&self, f: impl FnOnce(&Self::Var) -> bool) -> bool
true if this value is a variable satisfying the given
predicate, and false if it is a ground value.impl<T, X> Copy for Pattern<T, X>
impl<T, X> Eq for Pattern<T, X>
Source§impl<T, X> Ord for Pattern<T, X>
impl<T, X> Ord for Pattern<T, X>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T, X> PartialEq for Pattern<T, X>
impl<T, X> PartialEq for Pattern<T, X>
Source§impl<T, X> PartialOrd for Pattern<T, X>where
T: PartialOrd,
X: PartialOrd,
impl<T, X> PartialOrd for Pattern<T, X>where
T: PartialOrd,
X: PartialOrd,
impl<T, X> StructuralPartialEq for Pattern<T, X>
Auto Trait Implementations§
impl<T, X> Freeze for Pattern<T, X>
impl<T, X> RefUnwindSafe for Pattern<T, X>where
T: RefUnwindSafe,
X: RefUnwindSafe,
impl<T, X> Send for Pattern<T, X>
impl<T, X> Sync for Pattern<T, X>
impl<T, X> Unpin for Pattern<T, X>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.