pub enum PatternKind {
Wildcard,
Binding(Ident),
LitInt(i64),
LitFloat(f64),
LitBool(bool),
LitString(String),
Tuple(Vec<Pattern>),
Struct {
name: Ident,
fields: Vec<PatternField>,
},
Variant {
enum_name: Option<Ident>,
variant: Ident,
fields: Vec<Pattern>,
},
}Variants§
Wildcard
Wildcard pattern: _
Binding(Ident)
Binding pattern: x (binds the matched value to x)
LitInt(i64)
Literal pattern: 42, 3.14, true, "hello"
LitFloat(f64)
LitBool(bool)
LitString(String)
Tuple(Vec<Pattern>)
Tuple destructuring: (a, b, c)
Struct
Struct destructuring: Point { x, y } or Point { x: px, y: py }
Variant
Enum variant pattern: Some(x), None, Ok(v), Err(e)
Trait Implementations§
Source§impl Clone for PatternKind
impl Clone for PatternKind
Source§fn clone(&self) -> PatternKind
fn clone(&self) -> PatternKind
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PatternKind
impl RefUnwindSafe for PatternKind
impl Send for PatternKind
impl Sync for PatternKind
impl Unpin for PatternKind
impl UnsafeUnpin for PatternKind
impl UnwindSafe for PatternKind
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