pub enum LastPattern<P> {
Normal(P),
Ellipsis(Option<LocIdent>),
}Expand description
The last match in a data structure pattern. This can either be a normal match, or an ellipsis
which can capture the rest of the data structure. The type parameter P is the type of the
pattern of the data structure (ellipsis are supported for both array and record patterns).
§Example
- In
{foo={}, bar}, the last match is an normal match. - In
{foo={}, bar, ..}, the last match is a non-capturing ellipsis. - In
{foo={}, bar, ..rest}, the last match is a capturing ellipsis.
Variants§
Normal(P)
The last field is a normal match. In this case the pattern is “closed” so every record fields should be matched.
Ellipsis(Option<LocIdent>)
The pattern is “open” , ..}. Optionally you can bind a record containing the remaining
fields to an Identifier using the syntax , ..y}.
Trait Implementations§
Source§impl<P: Clone> Clone for LastPattern<P>
impl<P: Clone> Clone for LastPattern<P>
Source§fn clone(&self) -> LastPattern<P>
fn clone(&self) -> LastPattern<P>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<P: Debug> Debug for LastPattern<P>
impl<P: Debug> Debug for LastPattern<P>
Source§impl<P: PartialEq> PartialEq for LastPattern<P>
impl<P: PartialEq> PartialEq for LastPattern<P>
impl<P> StructuralPartialEq for LastPattern<P>
Auto Trait Implementations§
impl<P> Freeze for LastPattern<P>where
P: Freeze,
impl<P> RefUnwindSafe for LastPattern<P>where
P: RefUnwindSafe,
impl<P> Send for LastPattern<P>where
P: Send,
impl<P> Sync for LastPattern<P>where
P: Sync,
impl<P> Unpin for LastPattern<P>where
P: Unpin,
impl<P> UnsafeUnpin for LastPattern<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for LastPattern<P>where
P: UnwindSafe,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more