Enum rustc_pattern_analysis::pat::PatOrWild
source · pub(crate) enum PatOrWild<'p, Cx: TypeCx> {
Wild,
Pat(&'p DeconstructedPat<'p, Cx>),
}Expand description
Represents either a pattern obtained from user input or a wildcard constructed during the
algorithm. Do not use Wild to represent a wildcard pattern comping from user input.
This is morally Option<&'p DeconstructedPat> where None is interpreted as a wildcard.
Variants§
Wild
A non-user-provided wildcard, created during specialization.
Pat(&'p DeconstructedPat<'p, Cx>)
A user-provided pattern.
Implementations§
source§impl<'p, Cx: TypeCx> PatOrWild<'p, Cx>
impl<'p, Cx: TypeCx> PatOrWild<'p, Cx>
pub(crate) fn as_pat(&self) -> Option<&'p DeconstructedPat<'p, Cx>>
pub(crate) fn ctor(self) -> &'p Constructor<Cx>
pub(crate) fn is_or_pat(&self) -> bool
sourcepub(crate) fn flatten_or_pat(self) -> SmallVec<[Self; 1]>
pub(crate) fn flatten_or_pat(self) -> SmallVec<[Self; 1]>
Expand this (possibly-nested) or-pattern into its alternatives.
sourcepub(crate) fn specialize(
&self,
other_ctor: &Constructor<Cx>,
ctor_arity: usize
) -> SmallVec<[PatOrWild<'p, Cx>; 2]>
pub(crate) fn specialize( &self, other_ctor: &Constructor<Cx>, ctor_arity: usize ) -> SmallVec<[PatOrWild<'p, Cx>; 2]>
Specialize this pattern with a constructor.
other_ctor can be different from self.ctor, but must be covered by it.
pub(crate) fn set_useful(&self)
Trait Implementations§
impl<'p, Cx: TypeCx> Copy for PatOrWild<'p, Cx>
Auto Trait Implementations§
impl<'p, Cx> !RefUnwindSafe for PatOrWild<'p, Cx>
impl<'p, Cx> !Send for PatOrWild<'p, Cx>
impl<'p, Cx> !Sync for PatOrWild<'p, Cx>
impl<'p, Cx> Unpin for PatOrWild<'p, Cx>
impl<'p, Cx> !UnwindSafe for PatOrWild<'p, Cx>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes
Size for each variant:
Wild: 0 bytesPat: 8 bytes