pub enum Pattern {
Wildcard(Span),
Int(IntLit),
NegInt(NegIntLit),
Bool(BoolLit),
Path(PathPattern),
DataVariant {
base: Option<Box<Expr>>,
type_name: Ident,
variant: Ident,
bindings: Vec<PatternBinding>,
span: Span,
},
StructVariant {
base: Option<Box<Expr>>,
type_name: Ident,
variant: Ident,
fields: Vec<PatternFieldBinding>,
span: Span,
},
}Expand description
A pattern in a match arm.
Variants§
Wildcard(Span)
Wildcard pattern _ - matches anything
Int(IntLit)
Integer literal pattern (positive or zero)
NegInt(NegIntLit)
Negative integer literal pattern (e.g., -1, -42)
Bool(BoolLit)
Boolean literal pattern
Path(PathPattern)
Path pattern (e.g., Color::Red for enum variant)
DataVariant
Data variant pattern with bindings (e.g., Option::Some(x))
Fields
§
bindings: Vec<PatternBinding>Bindings for each field
StructVariant
Struct variant pattern with named field bindings (e.g., Shape::Circle { radius })
Implementations§
Trait Implementations§
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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
An iterator over the items within this container, by reference.
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
Check whether an item is contained within this sequence.
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
Convert an item of the sequence into a [
MaybeRef].