Derive Macro num_enum::Default

#[derive(Default)]
{
    // Attributes available to this derive:
    #[num_enum]
    #[default]
}
Expand description

Implements core::default::Default for a #[repr(Primitive)] enum.

ยงWhichever variant has the #[default] or #[num_enum(default)] attribute will be returned.

#[derive(Debug, Eq, PartialEq, num_enum::Default)]
#[repr(u8)]
enum Number {
    Zero,
    #[default]
    One,
}

assert_eq!(Number::One, Number::default());
assert_eq!(Number::One, <Number as ::core::default::Default>::default());