pub struct EnumVariantDef {
pub name: String,
pub fields: Vec<Type>,
pub field_names: Vec<String>,
}Expand description
A single variant in an enum definition.
Fields§
§name: StringVariant name
fields: Vec<Type>Field types for data variants. Empty for unit variants.
E.g., Some(i32) has fields = [Type::I32].
field_names: Vec<String>Field names for struct-style variants. Empty for unit and tuple variants.
When non-empty, field_names.len() == fields.len().
Implementations§
Source§impl EnumVariantDef
impl EnumVariantDef
Sourcepub fn is_struct_variant(&self) -> bool
pub fn is_struct_variant(&self) -> bool
Whether this is a struct-style variant (has named fields).
Sourcepub fn find_field(&self, name: &str) -> Option<usize>
pub fn find_field(&self, name: &str) -> Option<usize>
Find a field by name (for struct variants). Returns the field index.
Trait Implementations§
Source§impl Clone for EnumVariantDef
impl Clone for EnumVariantDef
Source§fn clone(&self) -> EnumVariantDef
fn clone(&self) -> EnumVariantDef
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EnumVariantDef
impl Debug for EnumVariantDef
Source§impl<'de> Deserialize<'de> for EnumVariantDef
impl<'de> Deserialize<'de> for EnumVariantDef
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for EnumVariantDef
impl RefUnwindSafe for EnumVariantDef
impl Send for EnumVariantDef
impl Sync for EnumVariantDef
impl Unpin for EnumVariantDef
impl UnsafeUnpin for EnumVariantDef
impl UnwindSafe for EnumVariantDef
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].