Available on
doc
or test
only.Expand description
Shows how to use the enumset!
declarative macro.
§Examples
This will create the ExampleEnum
and ExampleEnumSet
interrelated types.
enumset! {
/// An example created with [`enumset!`].
#[allow(dead_code)]
#[derive(Clone, Default)]
#[repr(u64)]
pub enum ExampleEnum<'a, 'b, T>(
/// Represents a set of [`ExampleEnum`] variants.
pub ExampleEnumSet: u8
)
[where T: Clone] // supports where clauses (between [])
{
#[default]
Variant0 = 1,
/// A tuple variant.
Variant1([u8; 3]),
/// A self-referential tuple variant.
#[cfg(feature = "std")]
Variant2(Box<Self>),
/// A struct variant with discriminant.
Variant3 {
/// field1 docs.
some: [u8; 2],
/// field2 docs.
other: u32
} = 30,
/// Supports generics and lifetimes.
Variant4(T, &'a str, &'b u32),
}
}
assert_eq![5, ExampleEnum::<()>::ENUM_VARIANTS];
Structs§
- Example
Enum Set - Represents a set of
ExampleEnum
variants.
Enums§
- Example
Enum - An example created with
enumset!
.