pub enum Pattern {
Wildcard {
name: String,
constraints: Option<WildcardConstraints>,
},
Exact(Expression),
Add(Vec<Pattern>),
Mul(Vec<Pattern>),
Pow(Box<Pattern>, Box<Pattern>),
Function {
name: String,
args: Vec<Pattern>,
},
}Expand description
A pattern that can match against expressions
Patterns support wildcards and structural matching to enable transformation rules and equation manipulation.
Variants§
Wildcard
Match any expression and bind to a name, optionally with constraints
Exact(Expression)
Match a specific expression exactly
Add(Vec<Pattern>)
Match addition with pattern terms (supports commutative matching)
Mul(Vec<Pattern>)
Match multiplication with pattern factors (supports commutative matching)
Pow(Box<Pattern>, Box<Pattern>)
Match power with pattern base and exponent
Function
Match function call with pattern arguments
Implementations§
Source§impl Pattern
impl Pattern
Sourcepub fn wildcard(name: impl Into<String>) -> Self
pub fn wildcard(name: impl Into<String>) -> Self
Create a simple wildcard pattern without constraints
Sourcepub fn wildcard_excluding(
name: impl Into<String>,
exclude: Vec<Expression>,
) -> Self
pub fn wildcard_excluding( name: impl Into<String>, exclude: Vec<Expression>, ) -> Self
Create a wildcard pattern with exclude constraints
Sourcepub fn wildcard_with_properties(
name: impl Into<String>,
properties: Vec<fn(&Expression) -> bool>,
) -> Self
pub fn wildcard_with_properties( name: impl Into<String>, properties: Vec<fn(&Expression) -> bool>, ) -> Self
Create a wildcard pattern with property constraints
Trait Implementations§
impl StructuralPartialEq for Pattern
Auto Trait Implementations§
impl Freeze for Pattern
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnwindSafe for Pattern
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more