Trait strum::EnumMessage[][src]

pub trait EnumMessage {
    fn get_message(&self) -> Option<&'static str>;
fn get_detailed_message(&self) -> Option<&'static str>;
fn get_serializations(&self) -> &'static [&'static str]
Notable traits for &'_ mut [u8]
impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
; }
Expand description

Associates additional pieces of information with an Enum. This can be autoimplemented by deriving EnumMessage and annotating your variants with `#[strum(message=“…”)].

Example

// You need to bring the type into scope to use it!!!
use strum::EnumMessage;

#[derive(PartialEq, Eq, Debug, EnumMessage)]
enum Pet {
    #[strum(message="I have a dog")]
    #[strum(detailed_message="My dog's name is Spots")]
    Dog,
    #[strum(message="I don't have a cat")]
    Cat,
}

let my_pet = Pet::Dog;
assert_eq!("I have a dog", my_pet.get_message().unwrap());

Required methods

Implementors