pub enum ConstructorSet<Cx: PatCx> {
Struct {
empty: bool,
},
Variants {
variants: IndexVec<Cx::VariantIdx, VariantVisibility>,
non_exhaustive: bool,
},
Ref,
Union,
Bool,
Integers {
range_1: IntRange,
range_2: Option<IntRange>,
},
Slice {
array_len: Option<usize>,
subtype_is_empty: bool,
},
Unlistable,
NoConstructors,
}
Expand description
Describes the set of all constructors for a type. For details, in particular about the emptiness of constructors, see the top of the file.
In terms of division of responsibility, ConstructorSet::split
handles all of the
exhaustive_patterns
feature.
Variants§
Struct
The type is a tuple or struct. empty
tracks whether the type is empty.
Variants
This type has the following list of constructors. If variants
is empty and
non_exhaustive
is false, don’t use this; use NoConstructors
instead.
Ref
The type is &T
.
Union
The type is a union.
Bool
Booleans.
Integers
The type is spanned by integer values. The range or ranges give the set of allowed values.
The second range is only useful for char
.
Slice
The type is matched by slices. array_len
is the compile-time length of the array, if
known. If subtype_is_empty
, all constructors are empty except possibly the zero-length
slice []
.
Unlistable
The constructors cannot be listed, and the type cannot be matched exhaustively. E.g. str
,
floats.
NoConstructors
The type has no constructors (not even empty ones). This is !
and empty enums.
Implementations§
Source§impl<Cx: PatCx> ConstructorSet<Cx>
impl<Cx: PatCx> ConstructorSet<Cx>
Sourcepub fn split<'a>(
&self,
ctors: impl Iterator<Item = &'a Constructor<Cx>> + Clone,
) -> SplitConstructorSet<Cx>where
Cx: 'a,
pub fn split<'a>(
&self,
ctors: impl Iterator<Item = &'a Constructor<Cx>> + Clone,
) -> SplitConstructorSet<Cx>where
Cx: 'a,
This analyzes a column of constructors to 1/ determine which constructors of the type (if
any) are missing; 2/ split constructors to handle non-trivial intersections e.g. on ranges
or slices. This can get subtle; see SplitConstructorSet
for details of this operation
and its invariants.