enum_fields

Attribute Macro enum_fields 

Source
#[enum_fields]
Expand description

A shorthand for setting repeating named fields in an enum’s variants.

Fields passed into this macro are set into every variant in the enum, but an optional “skip list” can be defined, by listing the variants to be skipped at the beginning, enclosed in “![]”.

§Example

use bfup_derive::enum_fields;

#[enum_fields(![Three] foo: i32, bar: u32)]
enum Numbers {
    One,
    Two{ skrzat: u8 },
    Three,
}

let one = Numbers::One { foo: 21, bar: 37 };
let two = Numbers::Two { foo: 5, bar: 5, skrzat: 42 };
let three = Numbers::Three;