#[non_exhaustive]pub enum Pat {
Ident(PatIdent),
Path(PatPath),
Reference(PatReference),
Struct(PatStruct),
Tuple(PatTuple),
TupleStruct(PatTupleStruct),
Type(PatType),
Wild(PatWild),
}Expand description
A pattern in a local binding, function signature, match expression, or various other places.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Ident(PatIdent)
A pattern that binds a new variable: ref mut binding @ SUBPATTERN.
Path(PatPath)
A path pattern like Color::Red.
Reference(PatReference)
A reference pattern: &mut var.
Struct(PatStruct)
A struct or struct variant pattern: Variant { x, y, .. }.
Tuple(PatTuple)
A tuple pattern: (a, b).
TupleStruct(PatTupleStruct)
A tuple struct or tuple variant pattern: Variant(x, y, .., z).
Type(PatType)
A type ascription pattern: foo: f64.
Wild(PatWild)
A pattern that matches any value: _.
Implementations§
Source§impl Pat
impl Pat
Sourcepub fn parse_single(input: ParseStream<'_>) -> Result<Self>
pub fn parse_single(input: ParseStream<'_>) -> Result<Self>
Parse a pattern that does not involve | at the top level.
Trait Implementations§
Source§impl From<PatReference> for Pat
impl From<PatReference> for Pat
Source§fn from(e: PatReference) -> Pat
fn from(e: PatReference) -> Pat
Converts to this type from the input type.
Source§impl From<PatTupleStruct> for Pat
impl From<PatTupleStruct> for Pat
Source§fn from(e: PatTupleStruct) -> Pat
fn from(e: PatTupleStruct) -> Pat
Converts to this type from the input type.
Source§impl ToTokens for Pat
impl ToTokens for Pat
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
Auto Trait Implementations§
impl Freeze for Pat
impl RefUnwindSafe for Pat
impl !Send for Pat
impl !Sync for Pat
impl Unpin for Pat
impl UnsafeUnpin for Pat
impl UnwindSafe for Pat
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,
Source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
Source§fn span(&self) -> Span
fn span(&self) -> Span
Returns a
Span covering the complete contents of this syntax tree
node, or Span::call_site() if this node is empty.