[−][src]Crate tyenum
Attribute macro for less verbose creation of enums having different types as variants. Also automatically implements From.
Usage:
struct A;
struct B;
struct C;
struct D;
#[tyenum]
enum Test {
A,
BB(B),
C(C),
}
results in:
enum Test {
A(A),
BB(B),
C(C),
}
impl From<A> for Test {
fn from(variant: A) -> Self {
Test::A(variant)
}
}
impl From<B> for Test {
fn from(variant: B) -> Self {
Test::BB(variant)
}
}
impl From<C> for Test {
fn from(variant: C) -> Self {
Test::C(variant)
}
}