pub enum MetaPattern {
Wildcard,
Var(Name),
Constructor(Name, Vec<MetaPattern>),
Literal(Literal),
As(Box<MetaPattern>, Name),
Or(Box<MetaPattern>, Box<MetaPattern>),
Inaccessible(Expr),
}Expand description
A pattern in a match expression.
Variants§
Wildcard
Wildcard pattern: matches anything, binds nothing.
Var(Name)
Variable pattern: matches anything, binds the value.
Constructor(Name, Vec<MetaPattern>)
Constructor pattern: matches if head is this constructor.
Literal(Literal)
Literal pattern: matches exact literal value.
As(Box<MetaPattern>, Name)
As-pattern: p as x matches p and also binds x.
Or(Box<MetaPattern>, Box<MetaPattern>)
Or-pattern: matches if either sub-pattern matches.
Inaccessible(Expr)
Inaccessible pattern (dot pattern): .e.
Implementations§
Source§impl MetaPattern
impl MetaPattern
Sourcepub fn is_irrefutable(&self) -> bool
pub fn is_irrefutable(&self) -> bool
Check if this pattern is a wildcard or variable.
Sourcepub fn is_constructor(&self) -> bool
pub fn is_constructor(&self) -> bool
Check if this pattern is a constructor pattern.
Sourcepub fn is_literal(&self) -> bool
pub fn is_literal(&self) -> bool
Check if this pattern is a literal.
Sourcepub fn ctor_name(&self) -> Option<&Name>
pub fn ctor_name(&self) -> Option<&Name>
Get the constructor name (if this is a constructor pattern).
Sourcepub fn subpatterns(&self) -> &[MetaPattern]
pub fn subpatterns(&self) -> &[MetaPattern]
Get the subpatterns (for constructor patterns).
Sourcepub fn num_bindings(&self) -> usize
pub fn num_bindings(&self) -> usize
Count the number of variables bound by this pattern.
Sourcepub fn bound_vars(&self) -> Vec<Name>
pub fn bound_vars(&self) -> Vec<Name>
Collect all variable names bound by this pattern.
Trait Implementations§
Source§impl Clone for MetaPattern
impl Clone for MetaPattern
Source§fn clone(&self) -> MetaPattern
fn clone(&self) -> MetaPattern
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MetaPattern
impl Debug for MetaPattern
Source§impl PartialEq for MetaPattern
impl PartialEq for MetaPattern
impl StructuralPartialEq for MetaPattern
Auto Trait Implementations§
impl Freeze for MetaPattern
impl RefUnwindSafe for MetaPattern
impl Send for MetaPattern
impl Sync for MetaPattern
impl Unpin for MetaPattern
impl UnsafeUnpin for MetaPattern
impl UnwindSafe for MetaPattern
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
Mutably borrows from an owned value. Read more