Enum rustc_ap_rustc_ast::ast::PatKind[][src]

pub enum PatKind {
Show variants Wild, Ident(BindingModeIdentOption<P<Pat>>), Struct(PathVec<PatField>, bool), TupleStruct(PathVec<P<Pat>>), Or(Vec<P<Pat>>), Path(Option<QSelf>, Path), Tuple(Vec<P<Pat>>), Box(P<Pat>), Ref(P<Pat>, Mutability), Lit(P<Expr>), Range(Option<P<Expr>>, Option<P<Expr>>, Spanned<RangeEnd>), Slice(Vec<P<Pat>>), Rest, Paren(P<Pat>), MacCall(MacCall),
}

Variants

Wild

Represents a wildcard pattern (_).

A PatKind::Ident may either be a new bound variable (ref mut binding @ OPT_SUBPATTERN), or a unit struct/variant pattern, or a const pattern (in the last two cases the third field must be None). Disambiguation cannot be done with parser alone, so it happens during name resolution.

Struct(PathVec<PatField>, bool)

A struct or struct variant pattern (e.g., Variant {x, y, ..}). The bool is true in the presence of a ...

TupleStruct(PathVec<P<Pat>>)

A tuple struct/variant pattern (Variant(x, y, .., z)).

Or(Vec<P<Pat>>)

An or-pattern A | B | C. Invariant: pats.len() >= 2.

Path(Option<QSelf>, Path)

A possibly qualified path pattern. Unqualified path patterns A::B::C can legally refer to variants, structs, constants or associated constants. Qualified path patterns <A>::B::C/<A as Trait>::B::C can only legally refer to associated constants.

Tuple(Vec<P<Pat>>)

A tuple pattern ((a, b)).

Box(P<Pat>)

A box pattern.

Ref(P<Pat>, Mutability)

A reference pattern (e.g., &mut (a, b)).

Lit(P<Expr>)

A literal.

A range pattern (e.g., 1...2, 1..=2 or 1..2).

Slice(Vec<P<Pat>>)

A slice pattern [a, b, c].

Rest

A rest pattern ...

Syntactically it is valid anywhere.

Semantically however, it only has meaning immediately inside:

  • a slice pattern: [a, .., b],
  • a binding pattern immediately inside a slice pattern: [a, r @ ..],
  • a tuple pattern: (a, .., b),
  • a tuple struct/variant pattern: $path(a, .., b).

In all of these cases, an additional restriction applies, only one rest pattern may occur in the pattern sequences.

Paren(P<Pat>)

Parentheses in patterns used for grouping (i.e., (PAT)).

MacCall(MacCall)

A macro pattern; pre-expansion.

Trait Implementations

impl Clone for PatKind[src]

fn clone(&self) -> PatKind[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for PatKind[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<__D: Decoder> Decodable<__D> for PatKind[src]

fn decode(__decoder: &mut __D) -> Result<Self, <__D as Decoder>::Error>[src]

impl<__E: Encoder> Encodable<__E> for PatKind[src]

fn encode(&self, __encoder: &mut __E) -> Result<(), <__E as Encoder>::Error>[src]

Auto Trait Implementations

impl !RefUnwindSafe for PatKind

impl !Send for PatKind

impl !Sync for PatKind

impl Unpin for PatKind

impl !UnwindSafe for PatKind

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

impl<T> Erased for T[src]