pub struct Enum {
    pub(super) name: String,
    pub(super) module_path: String,
    pub(super) discr_type: Option<Type>,
    pub(super) variants: Vec<Variant>,
    pub(super) flat: bool,
    pub(super) non_exhaustive: bool,
    pub(super) docstring: Option<String>,
}
Expand description

Represents an enum with named variants, each of which may have named and typed fields.

Enums are passed across the FFI by serializing to a bytebuffer, with a i32 indicating the variant followed by the serialization of each field.

Fields§

§name: String§module_path: String§discr_type: Option<Type>§variants: Vec<Variant>§flat: bool§non_exhaustive: bool§docstring: Option<String>

Implementations§

source§

impl Enum

source

pub fn name(&self) -> &str

source

pub fn variants(&self) -> &[Variant]

source

pub fn variant_discr(&self, variant_index: usize) -> Result<Literal>

source

pub fn variant_discr_type(&self) -> &Option<Type>

source

pub fn is_flat(&self) -> bool

source

pub fn is_non_exhaustive(&self) -> bool

source

pub fn iter_types(&self) -> TypeIterator<'_>

source

pub fn docstring(&self) -> Option<&str>

source

pub fn try_from_meta(meta: EnumMetadata, flat: bool) -> Result<Self>

Trait Implementations§

source§

impl AsType for Enum

source§

fn as_type(&self) -> Type

source§

impl Checksum for Enum

source§

fn checksum<__H: Hasher>(&self, state: &mut __H)

source§

impl Clone for Enum

source§

fn clone(&self) -> Enum

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Enum

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<Enum> for Enum

source§

fn eq(&self, other: &Enum) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Enum

source§

impl StructuralEq for Enum

source§

impl StructuralPartialEq for Enum

Auto Trait Implementations§

§

impl RefUnwindSafe for Enum

§

impl Send for Enum

§

impl Sync for Enum

§

impl Unpin for Enum

§

impl UnwindSafe for Enum

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.