pub trait VariantList{
const VARIANTS: [&'static str; Self::VARIANT_COUNT];
// Required method
fn variant_index(&self) -> usize;
// Provided method
fn variant_name(&self) -> String { ... }
}
Expand description
An enum trait that allows getting the index of its variant and thereby the name of the variant.
Required Associated Constants§
const VARIANTS: [&'static str; Self::VARIANT_COUNT]
Required Methods§
fn variant_index(&self) -> usize
Provided Methods§
fn variant_name(&self) -> String
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.