reword 5.0.0

Provides a macro to generate structures used for constant value lookup.
Documentation

reword

Travis Crates.io Docs

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.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.