[−][src]Enum rustc_mir_build::thir::pattern::_match::Constructor

enum Constructor<'tcx> {
    Single,
    Variant(DefId),
    ConstantValue(&'tcx Const<'tcx>),
    IntRange(IntRange<'tcx>),
    FloatRange(&'tcx Const<'tcx>, &'tcx Const<'tcx>, RangeEnd),
    Slice(Slice),
    NonExhaustive,
}

A value can be decomposed into a constructor applied to some fields. This struct represents the constructor. See also Fields.

pat_constructor retrieves the constructor corresponding to a pattern. specialize_one_pattern returns the list of fields corresponding to a pattern, given a constructor. Constructor::apply reconstructs the pattern from a pair of Constructor and Fields.

Variants

Single

The constructor for patterns that have a single constructor, like tuples, struct patterns and fixed-length arrays.

Variant(DefId)

Enum variants.

ConstantValue(&'tcx Const<'tcx>)

Literal values.

IntRange(IntRange<'tcx>)

Ranges of integer literal values (2, 2..=5 or 2..5).

FloatRange(&'tcx Const<'tcx>, &'tcx Const<'tcx>, RangeEnd)

Ranges of floating-point literal values (2.0..=5.2).

Slice(Slice)

Array and slice patterns.

NonExhaustive

Fake extra constructor for enums that aren't allowed to be matched exhaustively.

Implementations

impl<'tcx> Constructor<'tcx>[src]

fn is_slice(&self) -> bool[src]

fn variant_index_for_adt<'a>(
    &self,
    cx: &MatchCheckCtxt<'a, 'tcx>,
    adt: &'tcx AdtDef
) -> VariantIdx
[src]

fn subtract_ctors(
    &self,
    other_ctors: &Vec<Constructor<'tcx>>
) -> Vec<Constructor<'tcx>>
[src]

fn apply<'p>(
    &self,
    cx: &MatchCheckCtxt<'p, 'tcx>,
    ty: Ty<'tcx>,
    fields: Fields<'p, 'tcx>
) -> Pat<'tcx>
[src]

Apply a constructor to a list of patterns, yielding a new pattern. pats must have as many elements as this constructor's arity.

This is roughly the inverse of specialize_one_pattern.

Examples: self: Constructor::Single ty: (u32, u32, u32) pats: [10, 20, _] returns (10, 20, _)

self: Constructor::Variant(Option::Some) ty: Option<bool> pats: [false] returns Some(false)

fn apply_wildcards<'a>(
    &self,
    cx: &MatchCheckCtxt<'a, 'tcx>,
    ty: Ty<'tcx>
) -> Pat<'tcx>
[src]

Like apply, but where all the subpatterns are wildcards _.

Trait Implementations

impl<'tcx> Clone for Constructor<'tcx>[src]

impl<'tcx> Debug for Constructor<'tcx>[src]

impl<'tcx> PartialEq<Constructor<'tcx>> for Constructor<'tcx>[src]

impl<'tcx> StructuralPartialEq for Constructor<'tcx>[src]

Auto Trait Implementations

impl<'tcx> !RefUnwindSafe for Constructor<'tcx>

impl<'tcx> !Send for Constructor<'tcx>

impl<'tcx> !Sync for Constructor<'tcx>

impl<'tcx> Unpin for Constructor<'tcx>

impl<'tcx> !UnwindSafe for Constructor<'tcx>

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<'a, T> Captures<'a> 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> ToOwned for T where
    T: Clone, 
[src]

type Owned = T

The resulting type after obtaining ownership.

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.