enumeration 썸네일형 리스트형 Rust Enumeration Macro pub trait Enumeration { fn value(&self) -> String; fn find(name: &str) -> Option where Self: Sized; fn valid(value: &str) -> bool; } #[macro_export] macro_rules! enumeration { ($enum:ident; $({$types:ident: $values:expr}),*) => { #[derive(Debug, PartialEq, Eq, Clone)] pub enum $enum { $($types,)* } impl Enumeration for $enum { fn value(&self) -> String { match self { $($enum::$types => String::f.. 이전 1 다음