Struct TypeUnion
pub struct TypeUnion { /* private fields */ }Expand description
A set of types representing the possible result types of a match expression.
TypeUnion enforces the set invariant: inserting a type that is already
present is a no-op. Order is not significant; two TypeUnion values are
equal if they contain the same types regardless of insertion order.
Implementations§
§impl TypeUnion
impl TypeUnion
pub fn new() -> TypeUnion
pub fn insert(&mut self, ty: Type) -> bool
pub fn insert(&mut self, ty: Type) -> bool
Insert ty if it is not already present. Returns whether it was inserted.
Type::Unknown is skipped — it carries no type information and should
not widen the union (e.g. an Expr::Error branch in a Match).
pub fn contains(&self, ty: &Type) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> impl Iterator<Item = &Type>
Trait Implementations§
§impl<'de> Deserialize<'de> for TypeUnion
impl<'de> Deserialize<'de> for TypeUnion
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TypeUnion, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TypeUnion, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl<'a> IntoIterator for &'a TypeUnion
impl<'a> IntoIterator for &'a TypeUnion
§impl IntoIterator for TypeUnion
impl IntoIterator for TypeUnion
§impl PartialEq for TypeUnion
Set equality: two unions are equal iff they contain the same types,
regardless of insertion order.
impl PartialEq for TypeUnion
Set equality: two unions are equal iff they contain the same types, regardless of insertion order.
§impl Serialize for TypeUnion
impl Serialize for TypeUnion
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for TypeUnion
Auto Trait Implementations§
impl Freeze for TypeUnion
impl RefUnwindSafe for TypeUnion
impl Send for TypeUnion
impl Sync for TypeUnion
impl Unpin for TypeUnion
impl UnwindSafe for TypeUnion
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.