pub enum Pattern {
Show 14 variants
Wild(Span),
Value(Expr),
Let(Name),
Type {
ty: Type,
bind: Option<Name>,
},
Variant {
path: Vec<Name>,
args: Vec<Pattern>,
},
Relational {
op: BinOp,
value: Expr,
},
Range {
from: Expr,
to: Expr,
},
Tuple(Vec<Pattern>),
List(Vec<Pattern>, Span),
Slice(Option<Box<Pattern>>),
Property {
ty: Option<Type>,
fields: Vec<(Name, Pattern)>,
},
Or(Box<Pattern>, Box<Pattern>),
And(Box<Pattern>, Box<Pattern>),
Not(Box<Pattern>),
}Variants§
Wild(Span)
Value(Expr)
A literal or a path to a value or a case (0, Mode.Idle); a
lone path may be a type too: the resolver and the checker tell.
Let(Name)
let e.
Type
Monster m, Monster.
Variant
Mode.Charging(let rate).
Relational
< 5.
Range
Tuple(Vec<Pattern>)
List(Vec<Pattern>, Span)
[1, let second, .., let last] (C#’s list pattern): an array’s, a
string’s or a list’s items, a .. among them at most once.
Slice(Option<Box<Pattern>>)
.. in a list pattern: the items it doesn’t name, .. let rest
matching them as a slice.
Property
{ Health: < 5 }, Monster { Health: < 5 }.
Or(Box<Pattern>, Box<Pattern>)
And(Box<Pattern>, Box<Pattern>)
Not(Box<Pattern>)
Implementations§
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 UnsafeUnpin 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
Mutably borrows from an owned value. Read more