pub enum Pattern {
Var {
var: Ident,
pos: Pos,
},
BindPattern {
var: Ident,
subpat: Box<Pattern>,
pos: Pos,
},
ConstInt {
val: i128,
pos: Pos,
},
ConstPrim {
val: Ident,
pos: Pos,
},
Term {
sym: Ident,
args: Vec<Pattern>,
pos: Pos,
},
Wildcard {
pos: Pos,
},
And {
subpats: Vec<Pattern>,
pos: Pos,
},
MacroArg {
index: usize,
pos: Pos,
},
}
Expand description
A pattern: the left-hand side of a rule.
Variants§
Var
A mention of a variable.
Equivalent either to a binding (which can be emulated with
BindPattern
with a Pattern::Wildcard
subpattern), if this
is the first mention of the variable, in order to capture its
value; or else a match of the already-captured value. This
disambiguation happens when we lower ast
nodes to sema
nodes as we resolve bound variable names.
BindPattern
An operator that binds a variable to a subterm and matches the subpattern.
ConstInt
An operator that matches a constant integer value.
ConstPrim
An operator that matches an external constant value.
Term
An application of a type variant or term.
Wildcard
An operator that matches anything.
And
N sub-patterns that must all match.
MacroArg
Internal use only: macro argument in a template.
Implementations§
Source§impl Pattern
impl Pattern
pub fn root_term(&self) -> Option<&Ident>
Sourcepub fn terms(&self, f: &mut dyn FnMut(Pos, &Ident))
pub fn terms(&self, f: &mut dyn FnMut(Pos, &Ident))
Call f
for each of the terms in this pattern.