#[non_exhaustive]#[repr(C)]pub struct Variant<'shape> {
pub name: &'shape str,
pub discriminant: Option<i64>,
pub attributes: &'shape [VariantAttribute<'shape>],
pub data: StructType<'shape>,
pub doc: &'shape [&'shape str],
}Expand description
Describes a variant of an enum
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: &'shape strName of the jariant, e.g. Foo for enum FooBar { Foo, Bar }
discriminant: Option<i64>Discriminant value (if available). Might fit in a u8, etc.
attributes: &'shape [VariantAttribute<'shape>]Attributes set for this variant via the derive macro
data: StructType<'shape>Fields for this variant (empty if unit, number-named if tuple). IMPORTANT: the offset for the fields already takes into account the size & alignment of the discriminant.
doc: &'shape [&'shape str]Doc comment for the variant
Implementations§
Source§impl<'shape> Variant<'shape>
impl<'shape> Variant<'shape>
Sourcepub const fn builder() -> VariantBuilder<'shape>
pub const fn builder() -> VariantBuilder<'shape>
Returns a builder for Variant
Sourcepub fn has_arbitrary_attr(&self, content: &'static str) -> bool
pub fn has_arbitrary_attr(&self, content: &'static str) -> bool
Checks whether the Variant has an attribute of form VariantAttribute::Arbitrary with the
given content.
Trait Implementations§
impl<'shape> Copy for Variant<'shape>
impl<'shape> Eq for Variant<'shape>
impl<'shape> StructuralPartialEq for Variant<'shape>
Auto Trait Implementations§
impl<'shape> Freeze for Variant<'shape>
impl<'shape> RefUnwindSafe for Variant<'shape>
impl<'shape> Send for Variant<'shape>
impl<'shape> Sync for Variant<'shape>
impl<'shape> Unpin for Variant<'shape>
impl<'shape> UnwindSafe for Variant<'shape>
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