Enum hir_def::hir::Pat

source ·
pub enum Pat {
Show 15 variants Missing, Wild, Tuple { args: Box<[PatId]>, ellipsis: Option<u32>, }, Or(Box<[PatId]>), Record { path: Option<Box<Path>>, args: Box<[RecordFieldPat]>, ellipsis: bool, }, Range { start: Option<Box<LiteralOrConst>>, end: Option<Box<LiteralOrConst>>, }, Slice { prefix: Box<[PatId]>, slice: Option<PatId>, suffix: Box<[PatId]>, }, Path(Path), Lit(ExprId), Bind { id: BindingId, subpat: Option<PatId>, }, TupleStruct { path: Option<Box<Path>>, args: Box<[PatId]>, ellipsis: Option<u32>, }, Ref { pat: PatId, mutability: Mutability, }, Box { inner: PatId, }, ConstBlock(ExprId), Expr(ExprId),
}
Expand description

Close relative to rustc’s hir::PatKind

Variants§

§

Missing

§

Wild

§

Tuple

Fields

§args: Box<[PatId]>
§ellipsis: Option<u32>
§

Or(Box<[PatId]>)

§

Record

Fields

§path: Option<Box<Path>>
§ellipsis: bool
§

Range

§

Slice

Fields

§prefix: Box<[PatId]>
§slice: Option<PatId>
§suffix: Box<[PatId]>
§

Path(Path)

This might refer to a variable if a single segment path (specifically, on destructuring assignment).

§

Lit(ExprId)

§

Bind

Fields

§subpat: Option<PatId>
§

TupleStruct

Fields

§path: Option<Box<Path>>
§args: Box<[PatId]>
§ellipsis: Option<u32>
§

Ref

Fields

§pat: PatId
§mutability: Mutability
§

Box

Fields

§inner: PatId
§

ConstBlock(ExprId)

§

Expr(ExprId)

An expression inside a pattern. That can only occur inside assignments.

E.g. in (a, *b) = (1, &mut 2), *b is an expression.

Implementations§

source§

impl Pat

source

pub fn walk_child_pats(&self, f: impl FnMut(PatId))

Trait Implementations§

source§

impl Clone for Pat

source§

fn clone(&self) -> Pat

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Pat

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Pat

source§

fn eq(&self, other: &Pat) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Pat

source§

impl StructuralPartialEq for Pat

Auto Trait Implementations§

§

impl Freeze for Pat

§

impl RefUnwindSafe for Pat

§

impl Send for Pat

§

impl Sync for Pat

§

impl Unpin for Pat

§

impl UnwindSafe for Pat

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send> for T
where T: Any + Send,

§

fn into_box(self) -> Box<dyn Any + Send>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Sync + Send> for T
where T: Any + Send + Sync,

§

fn into_box(self) -> Box<dyn Any + Sync + Send>

Convert self into the appropriate boxed form.
source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more