#[derive(EnumAll)]
{
// Attributes available to this derive:
#[enum_all]
}
Expand description
Generate an array of all variants and a variant count.
This macro generates inherent constants on the enum:
const ALL: [Self; N]const COUNT: usize
ALL requires unit enums (it builds an array of variant values). For
non-unit enums, use #[enum_all(all(disable))] to derive only COUNT, or
#[enum_all(skip)] on the non-unit variants.
§Container attributes
#[enum_all(all(name = ..., vis = "...", enable/disable))]: control theALLconstant#[enum_all(count(name = ..., vis = "...", enable/disable))]: control theCOUNTconstant
§Variant attributes
#[enum_all(skip)]: exclude this variant fromALLandCOUNT
§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]);
assert_eq!(Foo::COUNT, 2);