pub struct DiscriminantTable { /* private fields */ }Expand description
The literals that name a union’s members. Each literal names one member,
except undefined: every member whose discriminant is optional reads it
when the field is absent, so it may name several.
Implementations§
Source§impl DiscriminantTable
impl DiscriminantTable
pub fn iter(&self) -> impl Iterator<Item = (&LiteralValue, &VariantIdx)>
Sourcepub fn get(&self, value: &LiteralValue) -> Option<VariantIdx>
pub fn get(&self, value: &LiteralValue) -> Option<VariantIdx>
The member value names, when it names exactly one.
Sourcepub fn variants_for<'a>(
&'a self,
value: &'a LiteralValue,
) -> impl Iterator<Item = VariantIdx> + 'a
pub fn variants_for<'a>( &'a self, value: &'a LiteralValue, ) -> impl Iterator<Item = VariantIdx> + 'a
Every member value names.
Sourcepub fn has_other_values(
&self,
variant: VariantIdx,
value: &LiteralValue,
) -> bool
pub fn has_other_values( &self, variant: VariantIdx, value: &LiteralValue, ) -> bool
Whether some literal other than value also names variant, so a
test against value alone can’t rule it out.
Sourcepub fn is_covered(
&self,
variant: VariantIdx,
covered: &BTreeSet<LiteralValue>,
) -> bool
pub fn is_covered( &self, variant: VariantIdx, covered: &BTreeSet<LiteralValue>, ) -> bool
Whether a switch covering covered handles variant: every value
that names it is a case.
Sourcepub fn uncovered_members(
&self,
members: &[Type],
covered: &BTreeSet<LiteralValue>,
) -> Vec<Type>
pub fn uncovered_members( &self, members: &[Type], covered: &BTreeSet<LiteralValue>, ) -> Vec<Type>
The members a switch covering covered still leaves possible.
Sourcepub fn uncovered(&self, covered: &BTreeSet<LiteralValue>) -> Vec<LiteralValue>
pub fn uncovered(&self, covered: &BTreeSet<LiteralValue>) -> Vec<LiteralValue>
The values covered leaves out, each once, in table order.
Sourcepub fn partition(
&self,
members: &[Type],
literal: &LiteralValue,
) -> Option<(Vec<Type>, Vec<Type>)>
pub fn partition( &self, members: &[Type], literal: &LiteralValue, ) -> Option<(Vec<Type>, Vec<Type>)>
members split by a test against literal: the members it names,
and the ones still possible when the test fails. A named member stays
on both sides when another value also names it, as an optional
kind?: "a" does with undefined. None when literal names none.