Macro enumx_derive::def_impls [−][src]
def_impls!() { /* proc-macro */ }
defines enums, with the syntax support of
-
generates a range of
enum
s in the syntax ofEnum![ range ]
-
implements traits for enums the variants of which have implemented
Example
The macro below generates enum type Enum1
, Enum2
Enum3
with 1,2,3 variants of generic types respectively.
The optional impl blocks implement Clone and Display for these enum types.
def_impls! { #[derive( Debug, PartialEq )] pub enum Enum[ 1..=3 ] where _Variants!(): Clone; impl Clone for Enum!(1..=3) where _Variants!(): Clone { fn clone( &self ) -> Self { _match!( _enum!( _variant!().clone() )) } } impl Display for Enum!(1..=3) where _Variants!(): Display { fn fmt( &self, f: &mut std::fmt::Formatter ) -> std::fmt::Result { _match!( _variant!().fmt(f) ) } } }