Trait Enum

Source
pub unsafe trait Enum:
    DeserializeOwned
    + FromStr
    + Copy
    + 'static {
    const COUNT: usize;
    const VARIANTS: &'static [Self];
    const NAMES: &'static [&'static str];

    // Required method
    fn discriminant(&self) -> usize;

    // Provided methods
    fn name(&self) -> &'static str { ... }
    fn from_name(s: &str) -> Option<Self> { ... }
}

Required Associated Constants§

Source

const COUNT: usize

Source

const VARIANTS: &'static [Self]

Source

const NAMES: &'static [&'static str]

Required Methods§

Provided Methods§

Source

fn name(&self) -> &'static str

Source

fn from_name(s: &str) -> Option<Self>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§