Integral enum
Rust derive-macro that simplifies integral enum creation
Example
use IntegralEnum;
/// Simple meaningful enum
/// (!) repr attribute defaults to u8, to specify custom repr
/// use built-in attribute #[repr(integral_value)] it
/// can contain only integral values
/// like u8, u16, u32, u64, u128 and its signed equivalents.
///
/// WARNING: if no explicit #[repr(...)] specified u8 will be used
/// as the underlying integral type, actual enum still can have u16 representation,
/// for example. For most cases this is enough, but if your enum is large
/// enough - specify explicit representation.
/// FIXME: Add automatic representation determining
// Test it
assert_eq!;
assert_eq!;
assert_eq!;
Macro will automatically generate the following trait implementations: TryFrom, Clone, Copy, PartialEq, Eq, Display, Debug
if you want to disable certain implementation, consider the #[enum_disable(...)] attribute,
items can be: clone, copy, display, debug, total_eq, partial_eq, try_from
- Some of these attributes are dependant, for example
Copydepends onClone, so if you disableClonegeneration,Copygeneration will be disabled also. total_eqdisablesEqtrait implementation
Example:
use IntegralEnum;
println!; // Compile error
TODO
- Do we really need to implement
PartialOrd + Ordalso?