[][src]Trait strum::EnumMessage

pub trait EnumMessage {
    pub fn get_message(&self) -> Option<&str>;
pub fn get_detailed_message(&self) -> Option<&str>;
pub fn get_serializations(&self) -> &[&str]; }

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


// 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")]
    #[strum(message="I don't have a cat")]

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

Required methods

pub fn get_message(&self) -> Option<&str>[src]

pub fn get_detailed_message(&self) -> Option<&str>[src]

pub fn get_serializations(&self) -> &[&str][src]

Loading content...


Loading content...