Documentation
See the enumx book for more.
What's new
-
macros for enum trait implementation delegated to its variants.
Provides_Variants!()
,_Variant!()
,_variant!()
,_match!()
,_enum!()
insidedef_impls!{}
.def_impls! { impl<T0,T1> Clone for Enum2<T0,T1> where _Variants!(): Clone { fn clone( &self ) -> Self { _match!( _enum!( _variant!().clone() ) ) } } }
Predefined impls for frequently used std traits:
impl_trait!{ Iterator _for!( Type )}
Note: User defined
enum
s are also supported. -
Allows functions returning
-> impl Trait
to return different types as long as they implemented the trait.#[sum] fn f( cond: bool ) -> impl Clone { if cond { #[variant] 1_i32 } else { #[variant] "false" } }