[−][src]Crate reword
Provides a macro to generate structures used for value lookup.
reword::reword! { enum Lang: &'static str { fn hi { NO = "Hei"; EN_UK | EN_US = "Hi"; } fn fall { NO = "Høst"; EN_UK = "Autumn"; EN_US = "Fall"; } } } let mut lang = Lang::NO; assert_eq!(lang.hi(), "Hei"); assert_eq!(lang.fall(), "Høst"); lang = Lang::EN_UK; assert_eq!(lang.hi(), "Hi"); assert_eq!(lang.fall(), "Autumn"); lang = Lang::EN_US; assert_eq!(lang.hi(), "Hi"); assert_eq!(lang.fall(), "Fall");
Attributes can be attached to both the enum
and the methods generated.
The Copy
, Clone
, Debug
, Eq
, PartialEq
, Ord
, PartialOrd
, and Hash
traits are
automatically derived for the enum
using the derive attribute.
Macros
reword | The macro used to generate the structures used for constant value lookup. |