[−][src]Enum rustc_mir_build::thir::pattern::_match::Constructor
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
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).
Ranges of floating-point literal values (2.0..=5.2).
Slice(Slice)Array and slice patterns.
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]
&self,
cx: &MatchCheckCtxt<'a, 'tcx>,
adt: &'tcx AdtDef
) -> VariantIdx
fn subtract_ctors(
&self,
other_ctors: &Vec<Constructor<'tcx>>
) -> Vec<Constructor<'tcx>>[src]
&self,
other_ctors: &Vec<Constructor<'tcx>>
) -> Vec<Constructor<'tcx>>
fn apply<'p>(
&self,
cx: &MatchCheckCtxt<'p, 'tcx>,
ty: Ty<'tcx>,
fields: Fields<'p, 'tcx>
) -> Pat<'tcx>[src]
&self,
cx: &MatchCheckCtxt<'p, 'tcx>,
ty: Ty<'tcx>,
fields: Fields<'p, 'tcx>
) -> Pat<'tcx>
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]
&self,
cx: &MatchCheckCtxt<'a, 'tcx>,
ty: Ty<'tcx>
) -> Pat<'tcx>
Like apply, but where all the subpatterns are wildcards _.
Trait Implementations
impl<'tcx> Clone for Constructor<'tcx>[src]
fn clone(&self) -> Constructor<'tcx>[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<'tcx> Debug for Constructor<'tcx>[src]
impl<'tcx> PartialEq<Constructor<'tcx>> for Constructor<'tcx>[src]
fn eq(&self, other: &Constructor<'tcx>) -> bool[src]
fn ne(&self, other: &Constructor<'tcx>) -> bool[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,