Enum syn::Pat
[−]
[src]
pub enum Pat { Wild, Ident(BindingMode, Ident, Option<Box<Pat>>), Struct(Path, Vec<FieldPat>, bool), TupleStruct(Path, Vec<Pat>, Option<usize>), Path(Option<QSelf>, Path), Tuple(Vec<Pat>, Option<usize>), Box(Box<Pat>), Ref(Box<Pat>, Mutability), Lit(Box<Expr>), Range(Box<Expr>, Box<Expr>), Slice(Vec<Pat>, Option<Box<Pat>>, Vec<Pat>), Mac(Mac), }
Variants
Wild
Represents a wildcard pattern (_
)
Ident(BindingMode, Ident, Option<Box<Pat>>)
A Pat::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(Path, Vec<FieldPat>, bool)
A struct or struct variant pattern, e.g. Variant {x, y, ..}
.
The bool
is true
in the presence of a ..
.
TupleStruct(Path, Vec<Pat>, Option<usize>)
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()
Path(Option<QSelf>, Path)
A possibly qualified path pattern.
Unquailfied path patterns A::B::C
can legally refer to variants, structs, constants
or associated constants. Quailfied path patterns <A>::B::C
/<A as Trait>::B::C
can
only legally refer to associated constants.
Tuple(Vec<Pat>, Option<usize>)
A tuple pattern (a, b)
.
If the ..
pattern fragment is present, then Option<usize>
denotes its position.
0 <= position <= subpats.len()
Box(Box<Pat>)
A box
pattern
Ref(Box<Pat>, Mutability)
A reference pattern, e.g. &mut (a, b)
Lit(Box<Expr>)
A literal
Range(Box<Expr>, Box<Expr>)
A range pattern, e.g. 1...2
Slice(Vec<Pat>, Option<Box<Pat>>, Vec<Pat>)
[a, b, ..i, y, z]
is represented as:
Pat::Slice(box [a, b], Some(i), box [y, z])
Mac(Mac)
A macro pattern; pre-expansion
Trait Implementations
impl ToTokens for Pat
[src]
impl Debug for Pat
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Clone for Pat
[src]
fn clone(&self) -> Pat
[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 Eq for Pat
[src]
impl PartialEq for Pat
[src]
fn eq(&self, __arg_0: &Pat) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Pat) -> bool
[src]
This method tests for !=
.