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.
pub fn make_macro_template(&self, macro_args: &[Ident]) -> Pattern
pub fn subst_macro_args(&self, macro_args: &[Pattern]) -> Option<Pattern>
pub fn pos(&self) -> Pos
Trait Implementations§
impl Eq for Pattern
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§
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)