#[derive(EnumArray)]
{
// Attributes available to this derive:
#[enum_array]
}
Expand description
Automatically generate a COUNT and VARIANTS constant for enum.
§Where to use:
- When you want to all variants of enum
- When you want to count of enum
§Note:
VARIANTSorder is same as enum definition order. not calculate the discriminant value.
§EnumAttribute: none
§Variant Attribute: none
§Examples
§Normal
use more_convert::EnumArray;
#[derive(EnumArray, Clone, Copy, Debug, PartialEq)]
pub enum Test {
Zero = 1,
Three = 3,
Two = 2,
}
assert_eq!(Test::COUNT, 3usize);
// order is same as enum definition order.
// not calculate the discriminant value.
assert_eq!(Test::VARIANTS, &[Test::Zero, Test::Three, Test::Two]);