| Crates.io | variant_count |
| lib.rs | variant_count |
| version | 1.2.0 |
| created_at | 2018-11-01 22:15:41.476219+00 |
| updated_at | 2025-06-20 19:29:41.889462+00 |
| description | Derive macro for enum which adds to it the count of variants. |
| homepage | |
| repository | https://github.com/XX/variant_count |
| max_upload_size | |
| id | 94100 |
| size | 8,094 |
This crate provides VariantCount derive macro for enum which adds to it the VARIANT_COUNT constant, containing count of enum variants.
The VariantCount usage example:
#[derive(VariantCount)]
enum Test {
First(i32),
Second(Option<String>),
Third,
}
assert_eq!(Test::VARIANT_COUNT, 3);
If you're using Cargo, just add it to your Cargo.toml:
[dependencies]
variant_count = "1.2"
MIT