Trait enum_traits::Discriminant
[−]
[src]
pub trait Discriminant: Sized { type Type; fn from_discriminant(discriminant: Self::Type) -> Option<Self>; unsafe fn from_discriminant_unchecked(discriminant: Self::Type) -> Self; }
Derive this trait for an enum automatically using #[derive(EnumDiscriminant)]
This trait can only be derived when every item have an explicitly defined discriminant.
Associated Types
type Type
The type of the discriminant
Required Methods
fn from_discriminant(discriminant: Self::Type) -> Option<Self>
Tries to construct an enum from the discriminant of the variants/enum items
unsafe fn from_discriminant_unchecked(discriminant: Self::Type) -> Self
Constructs an enum from the discriminant of the variants/enum items