pub enum PatKind {
Wild,
Ident(BindingMode, Ident, Option<P<Pat>>),
Struct(Path, Vec<Spanned<FieldPat>>, bool),
TupleStruct(Path, Vec<P<Pat>>, Option<usize>),
Path(Option<QSelf>, Path),
Tuple(Vec<P<Pat>>, Option<usize>),
Box(P<Pat>),
Ref(P<Pat>, Mutability),
Lit(P<Expr>),
Range(P<Expr>, P<Expr>, Spanned<RangeEnd>),
Slice(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>),
Paren(P<Pat>),
Mac(Mac),
}
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.
A struct or struct variant pattern (e.g., Variant {x, y, ..}
).
The bool
is true
in the presence of a ..
.
A tuple struct/variant pattern (Variant(x, y, .., z)
).
If the ..
pattern fragment is present, then Option<usize>
denotes its position.
0 <= position <= subpats.len()
.
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.
A tuple pattern ((a, b)
).
If the ..
pattern fragment is present, then Option<usize>
denotes its position.
0 <= position <= subpats.len()
.
A reference pattern (e.g., &mut (a, b)
).
A range pattern (e.g., 1...2
, 1..=2
or 1..2
).
[a, b, ..i, y, z]
is represented as:
PatKind::Slice(box [a, b], Some(i), box [y, z])
Parentheses in patterns used for grouping (i.e., (PAT)
).
A macro pattern; pre-expansion.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Create an error for a missing method specialization. Defaults to panicking with type, trait & method names. S
is the encoder/decoder state type, T
is the type being encoded/decoded, and the arguments are the names of the trait and method that should've been overridden. Read more