struct_enum

Attribute Macro struct_enum 

Source
#[struct_enum]
Expand description

Creates a From<..> implementation for each variant of the attached enum.

ยงExample

use shebling_codegen::struct_enum;

struct Foo {
    foo: u32,
}

#[struct_enum]
enum Bar {
    Foo(Foo),
}

let bar = Bar::from(Foo { foo: 17 });
assert!(matches!(bar, Bar::Foo(_)));