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::Target, &X::Target>
pub fn as_deref(&self) -> Pattern<&T::Target, &X::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.