enum_variant_macros 0.3.0

Macros to generate From & TryFrom for enums
Documentation
use enum_variant_macros::*;
use strum_macros::IntoStaticStr;

#[allow(dead_code)]
#[derive(IntoStaticStr, TryFromVariants)]
enum GenEnum {
    Word(u32),
    NotWord(i8),
}

#[test]
fn error_as_expected() {
    let a = GenEnum::NotWord(0);
    let b = u32::try_from(a);
    let b = b.err().expect("Succeeded in casting incorrect enum");
    assert_eq!("GenEnum", b.enum_type);
    assert_eq!("u32", b.exp_type);
    assert_eq!("NotWord", b.variant_name);
}