pub struct DeconstructedPat<Cx: TypeCx> { /* private fields */ }
Expand description
Values and patterns can be represented as a constructor applied to some fields. This represents
a pattern in this form. A DeconstructedPat
will almost always come from user input; the only
exception are some Wildcard
s introduced during pattern lowering.
Note that the number of fields may not match the fields declared in the original struct/variant.
This happens if a private or non_exhaustive
field is uninhabited, because the code mustn’t
observe that it is uninhabited. In that case that field is not included in fields
. Care must
be taken when converting to/from thir::Pat
.
Implementations§
source§impl<Cx: TypeCx> DeconstructedPat<Cx>
impl<Cx: TypeCx> DeconstructedPat<Cx>
pub fn wildcard(ty: Cx::Ty) -> Self
pub fn new( ctor: Constructor<Cx>, fields: Vec<DeconstructedPat<Cx>>, ty: Cx::Ty, data: Cx::PatData ) -> Self
pub fn ctor(&self) -> &Constructor<Cx>
pub fn ty(&self) -> &Cx::Ty
sourcepub fn data(&self) -> Option<&Cx::PatData>
pub fn data(&self) -> Option<&Cx::PatData>
Returns the extra data stored in a pattern. Returns None
if the pattern is a wildcard that
does not correspond to a user-supplied pattern.
pub fn iter_fields<'a>( &'a self ) -> impl Iterator<Item = &'a DeconstructedPat<Cx>>
Trait Implementations§
Auto Trait Implementations§
impl<Cx> RefUnwindSafe for DeconstructedPat<Cx>where
<Cx as TypeCx>::PatData: RefUnwindSafe,
<Cx as TypeCx>::StrLit: RefUnwindSafe,
<Cx as TypeCx>::Ty: RefUnwindSafe,
<Cx as TypeCx>::VariantIdx: RefUnwindSafe,
impl<Cx> Send for DeconstructedPat<Cx>
impl<Cx> Sync for DeconstructedPat<Cx>
impl<Cx> Unpin for DeconstructedPat<Cx>
impl<Cx> UnwindSafe for DeconstructedPat<Cx>where
<Cx as TypeCx>::PatData: UnwindSafe,
<Cx as TypeCx>::StrLit: UnwindSafe,
<Cx as TypeCx>::Ty: UnwindSafe,
<Cx as TypeCx>::VariantIdx: UnwindSafe,
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
Mutably borrows from an owned value. Read more