| Crates.io | enumeric |
| lib.rs | enumeric |
| version | 0.1.2 |
| created_at | 2025-06-06 15:07:45.661736+00 |
| updated_at | 2025-06-06 15:35:01.693144+00 |
| description | numeric range enum variant generation |
| homepage | |
| repository | https://github.com/hannahfluch/enumeric |
| max_upload_size | |
| id | 1703175 |
| size | 9,708 |
Procedural macro to automatically expand enum variants based on a numeric range.
use enumeric::range_enum;
#[range_enum]
enum MyEnum {
/// Expands to: Item0, Item1, Item2
#[range(0..3)]
Item,
/// This remains unchanged.
Other,
/// Expands to: Data10(u8), Data11(u8)
#[range(10..12)]
Data(u8),
/// Expands to: Code20 { id: u16 }, Code21 { id: u16 }, ..., Code22 { id: u16 }
#[range(20..=22)]
Code { id: u16 },
}
Currently supports #[range(start..end)] and #[range(start..=end)] syntax.
Only integer literals are accepted in the range.
Struct, tuple, and unit variants are all supported.