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

The type of the discriminant

Required Methods

Tries to construct an enum from the discriminant of the variants/enum items

Constructs an enum from the discriminant of the variants/enum items

Implementors