Struct rustc_hir::hir::Pat[][src]

pub struct Pat<'hir> {
    pub hir_id: HirId,
    pub kind: PatKind<'hir>,
    pub span: Span,
    pub default_binding_modes: bool,
}

Fields

hir_id: HirIdkind: PatKind<'hir>span: Spandefault_binding_modes: bool

Implementations

impl<'hir> Pat<'hir>[src]

fn walk_short_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool) -> bool[src]

pub fn walk_short(&self, it: impl FnMut(&Pat<'hir>) -> bool) -> bool[src]

Walk the pattern in left-to-right order, short circuiting (with .all(..)) if false is returned.

Note that when visiting e.g. Tuple(ps), if visiting ps[0] returns false, then ps[1] will not be visited.

fn walk_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool)[src]

pub fn walk(&self, it: impl FnMut(&Pat<'hir>) -> bool)[src]

Walk the pattern in left-to-right order.

If it(pat) returns false, the children are not visited.

pub fn walk_always(&self, it: impl FnMut(&Pat<'_>))[src]

Walk the pattern in left-to-right order.

If you always want to recurse, prefer this method over walk.

impl Pat<'_>[src]

pub fn each_binding(&self, f: impl FnMut(BindingAnnotation, HirId, Span, Ident))[src]

Call f on every “binding” in a pattern, e.g., on a in match foo() { Some(a) => (), None => () }

pub fn each_binding_or_first(
    &self,
    f: &mut impl FnMut(BindingAnnotation, HirId, Span, Ident)
)
[src]

Call f on every “binding” in a pattern, e.g., on a in match foo() { Some(a) => (), None => () }.

When encountering an or-pattern p_0 | ... | p_n only p_0 will be visited.

pub fn contains_bindings(&self) -> bool[src]

Checks if the pattern contains any patterns that bind something to an ident, e.g., foo, or Foo(foo) or foo @ Bar(..).

fn satisfies(&self, pred: impl Fn(&Pat<'_>) -> bool) -> bool[src]

Checks if the pattern satisfies the given predicate on some sub-pattern.

pub fn simple_ident(&self) -> Option<Ident>[src]

pub fn necessary_variants(&self) -> Vec<DefId>[src]

Returns variants that are necessary to exist for the pattern to match.

pub fn contains_explicit_ref_binding(&self) -> Option<Mutability>[src]

Checks if the pattern contains any ref or ref mut bindings, and if yes whether it contains mutable or just immutables ones.

Trait Implementations

impl<'hir> Debug for Pat<'hir>[src]

impl<'hir, __CTX> HashStable<__CTX> for Pat<'hir> where
    __CTX: HashStableContext
[src]

Auto Trait Implementations

impl<'hir> !RefUnwindSafe for Pat<'hir>

impl<'hir> !Send for Pat<'hir>

impl<'hir> !Sync for Pat<'hir>

impl<'hir> Unpin for Pat<'hir>

impl<'hir> !UnwindSafe for Pat<'hir>

Blanket Implementations

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

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

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

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

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

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.

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.