pub enum Pattern {
Identifier(String),
Typed {
name: String,
type_annotation: TypeAnnotation,
},
Literal(Literal),
Array(Vec<Pattern>),
Object(Vec<(String, Pattern)>),
Wildcard,
Constructor {
enum_name: Option<TypePath>,
variant: String,
fields: PatternConstructorFields,
},
}Expand description
Pattern for pattern matching
Variants§
Identifier(String)
Match a specific identifier and bind it
Typed
Match by type and bind identifier when the runtime value conforms
Literal(Literal)
Match a literal value
Array(Vec<Pattern>)
Match an array pattern
Object(Vec<(String, Pattern)>)
Match an object pattern
Wildcard
Match anything (underscore)
Constructor
Match a constructor pattern
Implementations§
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 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