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.
This also uses interior mutability to keep track of whether the pattern has been found reachable
during analysis. For this reason they cannot be cloned.
A DeconstructedPat
will almost always come from user input; the only exception are some
Wildcard
s introduced during specialization.
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.