This crate provides the EnumMacroGen
derive proc macro for Rust, which
simplifies handling variants of an enum. It generates declartive macros
according to a given template.
Example
use EnumMacroGen;
]
Instead of writing a match
statement to handle each variant of Test
, you
can use the handle_test!
a macro generated by EnumMacroGen
.
// <**GENERATED**>
// </**GENERATED**>
Deriving EnumMacroGen
To use EnumMacroGen
, simply add #[derive(EnumMacroGen)]
above your enum
declaration.
You can also specify the format of the generated macro with the enum_macro
attribute. The attribute value should be a token list containing $variant
and $fields
, which will be replaced with the variant name and fields,
respectively.