pub struct Pattern<'ast> {
pub data: PatternData<'ast>,
pub alias: Option<LocIdent>,
pub pos: TermPos,
}Expand description
A generic pattern, that can appear in a match expression (not yet implemented) or in a destructuring let-binding.
Fields§
§data: PatternData<'ast>The content of this pattern
alias: Option<LocIdent>A potential alias for this pattern, capturing the whole matched value. In the source
language, an alias is introduced by x @ <pattern>, where x is an arbitrary identifier.
pos: TermPosThe position of the pattern in the source.
Implementations§
Trait Implementations§
Source§impl CloneTo for Pattern<'_>
impl CloneTo for Pattern<'_>
Source§impl<'ast> TraverseAlloc<'ast, Ast<'ast>> for Pattern<'ast>
impl<'ast> TraverseAlloc<'ast, Ast<'ast>> for Pattern<'ast>
Source§fn traverse<F, E>(
self,
alloc: &'ast AstAlloc,
f: &mut F,
order: TraverseOrder,
) -> Result<Self, E>
fn traverse<F, E>( self, alloc: &'ast AstAlloc, f: &mut F, order: TraverseOrder, ) -> Result<Self, E>
Same as Traverse::traverse, but takes an additional AST allocator.
Source§fn traverse_ref<S, U>(
&'ast self,
f: &mut dyn FnMut(&'ast Ast<'ast>, &S) -> TraverseControl<S, U>,
scope: &S,
) -> Option<U>
fn traverse_ref<S, U>( &'ast self, f: &mut dyn FnMut(&'ast Ast<'ast>, &S) -> TraverseControl<S, U>, scope: &S, ) -> Option<U>
Same as Traverse::traverse_ref, but takes an additional AST allocator. Read more
fn find_map<S>(&'ast self, pred: impl FnMut(&'ast T) -> Option<S>) -> Option<S>where
T: Clone + 'ast,
impl Allocable for Pattern<'_>
impl<'ast> Eq for Pattern<'ast>
impl<'ast> StructuralPartialEq for Pattern<'ast>
Auto Trait Implementations§
impl<'ast> Freeze for Pattern<'ast>
impl<'ast> RefUnwindSafe for Pattern<'ast>
impl<'ast> Send for Pattern<'ast>
impl<'ast> Sync for Pattern<'ast>
impl<'ast> Unpin for Pattern<'ast>
impl<'ast> UnsafeUnpin for Pattern<'ast>
impl<'ast> UnwindSafe for Pattern<'ast>
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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