macro_rules! decodable_enum { ($(#[$meta:meta])* $visibility:vis enum $name:ident< $raw_type:ty, $error_type:ident, $error_path:ident > { $($(#[$variant_meta:meta])* $variant:ident = $val:expr),*, }) => { ... }; }
Expand description
Generates an enum value where each variant can be converted into a constant in the given raw_type.
For example: decodable_enum! { pub(crate) enum Color<u8, MyError, MyError::Variant> { Red = 1, Blue = 2, Green = 3, } }
Color::try_from(2) -> Color::Red u8::from(&Color::Red) -> 1.