pub enum Pattern {
Wildcard {
span: Span,
},
Variable {
name: Identifier,
span: Span,
},
Literal {
value: String,
span: Span,
},
Type {
name: NamePath,
span: Span,
},
Class {
name: NamePath,
fields: Vec<(Identifier, Option<Pattern>)>,
span: Span,
},
Else {
span: Span,
},
}Expand description
A pattern for matching
Variants§
Wildcard
A wildcard pattern that matches anything.
Variable
A variable pattern that binds the matched value.
Literal
A literal pattern.
Type
A type pattern for matching types.
Class
A class pattern for destructuring.
let Point { x, y } = p // shorthand syntax
let Point { x: a, y: b } = p // explicit binding
let Point { x, y: new_y } = p // mixed syntaxFields
§
fields: Vec<(Identifier, Option<Pattern>)>The field patterns. None for shorthand syntax.
Else
An else pattern (catch-all).
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
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 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