Enum cranelift_isle::ast::Pattern
source · [−]pub enum Pattern {
Var {
var: Ident,
pos: Pos,
},
BindPattern {
var: Ident,
subpat: Box<Pattern>,
pos: Pos,
},
ConstInt {
val: i64,
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
Fields
pos: Pos
An operator that matches anything.
And
N sub-patterns that must all match.
MacroArg
Internal use only: macro argument in a template.
Implementations
sourceimpl 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 StructuralEq for Pattern
impl StructuralPartialEq for Pattern
Auto Trait Implementations
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnwindSafe for Pattern
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more