Skip to main content

EnumAll

Derive Macro EnumAll 

Source
#[derive(EnumAll)]
{
    // Attributes available to this derive:
    #[enum_all]
}
Expand description

Derive the EnumAll trait and generate an array of all variants.

This macro generates:

  • impl EnumAll for T

§Container attributes

(none)

§Variant attributes

  • #[enum_all(skip)]: exclude this variant from the ALL array

§Example

use enum_helper::EnumAll;

#[derive(EnumAll, Debug, PartialEq, Eq)]
enum Foo {
    Bar,
    Baz,
    #[enum_all(skip)]
    Skipped
}

assert_eq!(Foo::ALL, [Foo::Bar, Foo::Baz]);