#[repr(C)]pub struct Variant {
pub name: &'static str,
pub discriminant: Option<i64>,
pub attributes: &'static [VariantAttribute],
pub data: StructType,
pub doc: &'static [&'static str],
}Expand description
Describes a variant of an enum
Fields§
§name: &'static strName of the variant, e.g. Foo for enum FooBar { Foo, Bar }
discriminant: Option<i64>Discriminant value (if available). Might fit in a u8, etc.
attributes: &'static [VariantAttribute]Attributes set for this variant via the derive macro
data: StructTypeFields 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: &'static [&'static str]Doc comment for the variant
Implementations§
Source§impl Variant
impl Variant
Sourcepub fn has_attr(&self, ns: Option<&str>, key: &str) -> bool
pub fn has_attr(&self, ns: Option<&str>, key: &str) -> bool
Checks whether the Variant has an attribute with the given namespace and key.
Use None for builtin attributes, Some("ns") for namespaced attributes.
Sourcepub fn get_attr(&self, ns: Option<&str>, key: &str) -> Option<&Attr>
pub fn get_attr(&self, ns: Option<&str>, key: &str) -> Option<&Attr>
Gets an attribute by namespace and key.
Use None for builtin attributes, Some("ns") for namespaced attributes.
Sourcepub fn has_builtin_attr(&self, key: &str) -> bool
pub fn has_builtin_attr(&self, key: &str) -> bool
Checks whether the Variant has a builtin attribute with the given key.
Sourcepub fn get_builtin_attr(&self, key: &str) -> Option<&Attr>
pub fn get_builtin_attr(&self, key: &str) -> Option<&Attr>
Gets a builtin attribute by key.