pub struct EnumDef {
pub name: String,
pub variants: Vec<EnumVariantDef>,
pub posture: Posture,
pub thread_safety: ThreadSafety,
pub is_pub: bool,
pub file_id: FileId,
pub destructor: Option<String>,
pub is_c_layout: bool,
}Expand description
Definition of an enum type.
Fields§
§name: StringEnum name
variants: Vec<EnumVariantDef>Variants in declaration order
posture: PostureFinal ownership posture (ADR-0080). Copy makes is_type_copy
return true for this enum directly; Linear makes is_type_linear
return true directly. Affine (the default) lets variant-payload
inference decide the practical posture.
thread_safety: ThreadSafetyADR-0084: final thread-safety classification (mirrors
StructDef.thread_safety).
is_pub: boolWhether this enum is public (visible outside its directory)
file_id: FileIdFile ID this enum was declared in (for visibility checking)
destructor: Option<String>User-defined destructor function name, if any (e.g., “Resource.__drop”).
ADR-0053 phase 3b. Mirrors StructDef.destructor.
is_c_layout: boolADR-0086: whether @mark(c) was applied. C-layout enums use
c_int as their discriminant type (regardless of variant count),
disable niche optimisation, and are eligible to cross the FFI
boundary by value.
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.
ADR-0086: @mark(c) enum types use c_int as their discriminant
(matching C’s default enum representation), regardless of variant
count. Other enums use the smallest unsigned integer that fits the
variant index.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for EnumDef
impl<'de> Deserialize<'de> for EnumDef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for EnumDef
impl RefUnwindSafe for EnumDef
impl Send for EnumDef
impl Sync for EnumDef
impl Unpin for EnumDef
impl UnsafeUnpin 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
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
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§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,
MaybeRef].