pub struct EnumDef {
pub name: String,
pub variants: Vec<EnumVariantDef>,
pub is_pub: bool,
pub file_id: FileId,
}Expand description
Definition of an enum type.
Fields§
§name: StringEnum name
variants: Vec<EnumVariantDef>Variants in declaration order
is_pub: boolWhether this enum is public (visible outside its directory)
file_id: FileIdFile ID this enum was declared in (for visibility checking)
Implementations§
Source§impl EnumDef
impl EnumDef
Sourcepub fn variant_count(&self) -> usize
pub fn variant_count(&self) -> usize
Get the number of variants in this enum.
Sourcepub fn find_variant(&self, name: &str) -> Option<usize>
pub fn find_variant(&self, name: &str) -> Option<usize>
Find a variant by name and return its index.
Sourcepub fn has_data_variants(&self) -> bool
pub fn has_data_variants(&self) -> bool
Whether any variant carries associated data.
Sourcepub fn is_unit_only(&self) -> bool
pub fn is_unit_only(&self) -> bool
Whether all variants are unit variants (no data).
Sourcepub fn discriminant_type(&self) -> Type
pub fn discriminant_type(&self) -> Type
Get the discriminant type for this enum. Returns the smallest unsigned integer type that can hold all variant indices.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EnumDef
impl RefUnwindSafe for EnumDef
impl Send for EnumDef
impl Sync for EnumDef
impl Unpin for EnumDef
impl UnwindSafe for EnumDef
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
An iterator over the items within this container, by reference.
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
Check whether an item is contained within this sequence.
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
Convert an item of the sequence into a [
MaybeRef].