pub enum Pattern {
Wildcard(Span),
Ident {
is_mut: bool,
name: Ident,
span: Span,
},
Int(IntLit),
NegInt(NegIntLit),
Bool(BoolLit),
Path(PathPattern),
DataVariant {
base: Option<Box<Expr>>,
type_name: Ident,
variant: Ident,
fields: Vec<TupleElemPattern>,
span: Span,
},
StructVariant {
base: Option<Box<Expr>>,
type_name: Ident,
variant: Ident,
fields: Vec<FieldPattern>,
span: Span,
},
Struct {
type_name: Ident,
fields: Vec<FieldPattern>,
span: Span,
},
Tuple {
elems: Vec<TupleElemPattern>,
span: Span,
},
ComptimeUnrollArm {
binding: Ident,
iterable: Box<Expr>,
span: Span,
},
}Expand description
A pattern in a let binding or match arm (ADR-0049).
A single recursive Pattern type is used in both contexts. Sema enforces
refutability per context (let requires irrefutable patterns, match accepts any).
Variants§
Wildcard(Span)
Wildcard pattern _ - matches anything, irrefutable
Ident
Named binding (x or mut x), irrefutable
Int(IntLit)
Integer literal pattern (positive or zero), refutable
NegInt(NegIntLit)
Negative integer literal pattern (e.g., -1, -42), refutable
Bool(BoolLit)
Boolean literal pattern, refutable
Path(PathPattern)
Path pattern (e.g., Color::Red for a unit enum variant), refutable
DataVariant
Data variant pattern with positional sub-patterns (e.g., Option::Some(x))
Fields
fields: Vec<TupleElemPattern>Sub-patterns for each field (may include .. via TupleElemPattern::Rest)
span: SpanStructVariant
Struct variant pattern with named field sub-patterns (e.g., Shape::Circle { radius })
Fields
fields: Vec<FieldPattern>Named field sub-patterns (may include .. via a field with field_name: None)
span: SpanStruct
Struct destructure pattern (e.g., Point { x, y }), irrefutable when all sub-patterns are.
Tuple
Tuple destructure pattern (e.g., (a, b) or (a, .., c)), irrefutable when all sub-patterns are.
ComptimeUnrollArm
ADR-0079 Phase 3: a comptime_unroll for arm template. Only
valid at the top level of a match arm — sema rejects it
elsewhere. The arm fires once per element of iterable; the
compiler synthesizes a variant-specific concrete pattern per
iteration and substitutes binding as a comptime value in
the arm body.
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>,
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
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
§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
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
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§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,
MaybeRef].