pub enum Pattern {
Literal(Expr),
Variant(String, Option<Box<Pattern>>, Span),
Wildcard(Span),
Ident(String, Span),
Guard {
inner: Box<Pattern>,
condition: Box<Expr>,
span: Span,
},
Or {
patterns: Vec<Pattern>,
span: Span,
},
ListDestructure {
elements: Vec<Pattern>,
rest: Option<String>,
span: Span,
},
TupleDestructure {
elements: Vec<Pattern>,
span: Span,
},
RecordDestructure {
type_name: String,
fields: Vec<(String, Option<Pattern>)>,
open: bool,
span: Span,
},
TypeCheck {
name: String,
type_expr: Box<TypeExpr>,
span: Span,
},
}Variants§
Literal(Expr)
Literal pattern: 200, “hello”, true
Variant(String, Option<Box<Pattern>>, Span)
Variant with optional sub-pattern: ok(value), err(e), Some(Value(n))
Wildcard(Span)
Wildcard: _
Ident(String, Span)
Ident binding
Guard
Guard: pattern if condition
Or
Or: pattern1 | pattern2
ListDestructure
List destructure: [a, b, …rest]
TupleDestructure
Tuple destructure: (a, b, c)
RecordDestructure
Record destructure: TypeName(field1:, field2: pat, ..)
TypeCheck
Type check: name: Type
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Pattern
impl<'de> Deserialize<'de> for Pattern
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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
Mutably borrows from an owned value. Read more