pub type DeconstructedPat<'p, 'tcx> = DeconstructedPat<RustcPatCtxt<'p, 'tcx>>;
Aliased Type§
struct DeconstructedPat<'p, 'tcx> {
ctor: Constructor<RustcPatCtxt<'p, 'tcx>>,
fields: Vec<IndexedPat<RustcPatCtxt<'p, 'tcx>>>,
arity: usize,
ty: RevealedTy<'tcx>,
data: &'p Pat<'tcx>,
pub(crate) uid: PatId,
}
Fields§
§ctor: Constructor<RustcPatCtxt<'p, 'tcx>>
§fields: Vec<IndexedPat<RustcPatCtxt<'p, 'tcx>>>
§arity: usize
The number of fields in this pattern. E.g. if the pattern is SomeStruct { field12: true, .. }
this would be the total number of fields of the struct.
This is also the same as self.ctor.arity(self.ty)
.
ty: RevealedTy<'tcx>
§data: &'p Pat<'tcx>
Extra data to store in a pattern.
uid: PatId
Globally-unique id used to track usefulness at the level of subpatterns.
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: 144 bytes
Implementations
Source§impl<Cx: PatCx> DeconstructedPat<Cx>
impl<Cx: PatCx> DeconstructedPat<Cx>
pub fn new( ctor: Constructor<Cx>, fields: Vec<IndexedPat<Cx>>, arity: usize, ty: Cx::Ty, data: Cx::PatData, ) -> Self
pub fn at_index(self, idx: usize) -> IndexedPat<Cx>
pub(crate) fn is_or_pat(&self) -> bool
pub fn ctor(&self) -> &Constructor<Cx>
pub fn ty(&self) -> &Cx::Ty
pub fn arity(&self) -> usize
pub fn iter_fields<'a>(&'a self) -> impl Iterator<Item = &'a IndexedPat<Cx>>
Sourcepub(crate) fn specialize<'a>(
&'a self,
other_ctor: &Constructor<Cx>,
other_ctor_arity: usize,
) -> SmallVec<[PatOrWild<'a, Cx>; 2]>
pub(crate) fn specialize<'a>( &'a self, other_ctor: &Constructor<Cx>, other_ctor_arity: usize, ) -> SmallVec<[PatOrWild<'a, Cx>; 2]>
Specialize this pattern with a constructor.
other_ctor
can be different from self.ctor
, but must be covered by it.
Trait Implementations
Source§impl<Cx: PatCx> Debug for DeconstructedPat<Cx>
impl<Cx: PatCx> Debug for DeconstructedPat<Cx>
This is best effort and not good enough for a Display
impl.
Source§impl<Cx: PatCx> Hash for DeconstructedPat<Cx>
impl<Cx: PatCx> Hash for DeconstructedPat<Cx>
Delegate to uid
.
Source§impl<Cx: PatCx> PartialEq for DeconstructedPat<Cx>
impl<Cx: PatCx> PartialEq for DeconstructedPat<Cx>
Delegate to uid
.
impl<Cx: PatCx> Eq for DeconstructedPat<Cx>
Delegate to uid
.