Skip to main content

Pat

Enum Pat 

Source
#[non_exhaustive]
pub enum Pat { Var { name: Identifier, pos: Pos, span: Span, }, Wild { pos: Pos, span: Span, }, Con { qualifier: Option<ModuleName>, name: Identifier, args: Vec<Self>, pos: Pos, span: Span, }, Record { qualifier: Option<ModuleName>, name: Identifier, syntax: RecordPatternSyntax, fields: Vec<PatFieldAssign>, pos: Pos, span: Span, }, Tuple { items: Vec<Self>, pos: Pos, span: Span, }, List { items: Vec<Self>, pos: Pos, span: Span, }, Lit { kind: LitKind, text: String, pos: Pos, span: Span, }, As { name: Identifier, pat: Box<Self>, pos: Pos, span: Span, }, Other { raw: String, pos: Pos, span: Span, }, }

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Var

Variable pattern.

Fields

§name: Identifier

Bound variable name.

§pos: Pos

Position of the variable token.

§span: Span

Span of the variable token.

§

Wild

Wildcard pattern (_).

Fields

§pos: Pos

Position of the _ token.

§span: Span

Span of the _ token.

§

Con

Constructor pattern with source-ordered arguments.

Fields

§qualifier: Option<ModuleName>

Optional module qualifier before the constructor name.

§name: Identifier

Constructor name.

§args: Vec<Self>

Constructor arguments in source order.

§pos: Pos

Position of the constructor token.

§span: Span

Span of the whole constructor pattern.

§

Record

Constructor record pattern with source-ordered fields.

Fields

§qualifier: Option<ModuleName>

Optional module qualifier before the constructor name.

§name: Identifier

Constructor name.

§syntax: RecordPatternSyntax

Whether fields used {..} or with.

§fields: Vec<PatFieldAssign>

Field patterns in source order.

§pos: Pos

Position of the constructor token.

§span: Span

Span of the whole record pattern.

§

Tuple

Tuple pattern with source-ordered items.

Fields

§items: Vec<Self>

Tuple items in source order.

§pos: Pos

Position of the opening parenthesis.

§span: Span

Span from ( through ).

§

List

List pattern with source-ordered items.

Fields

§items: Vec<Self>

List items in source order.

§pos: Pos

Position of the opening bracket.

§span: Span

Span from [ through ].

§

Lit

Literal pattern; text is the parser’s normalized literal text.

Fields

§kind: LitKind

Literal family.

§text: String

Normalized literal payload.

§pos: Pos

Position of the literal token.

§span: Span

Span of the literal token in the source.

§

As

name@pat

Fields

§name: Identifier

Name bound to the whole matched pattern.

§pat: Box<Self>

Pattern being aliased.

§pos: Pos

Position of the bound name.

§span: Span

Span of the whole name@pat pattern.

§

Other

Anything the parser couldn’t classify; raw text preserved.

Fields

§raw: String

Raw source text of the unclassified pattern.

§pos: Pos

Position of the raw pattern’s first token.

§span: Span

Span of the preserved raw pattern text.

Implementations§

Source§

impl Pat

Source

pub const fn pos(&self) -> Pos

Source

pub const fn span(&self) -> Span

Byte span covering the whole pattern.

Source

pub fn render(&self) -> String

Render back to compact, source-like text. Lossy and normalizing in the same way as Expr::render; use the node’s span for byte-faithful text.

Trait Implementations§

Source§

impl Clone for Pat

Source§

fn clone(&self) -> Pat

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 Display for Pat

Source§

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

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

impl Eq for Pat

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 (const: unstable) · 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 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 UnsafeUnpin 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, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.