Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 962 Bytes

File metadata and controls

38 lines (26 loc) · 962 Bytes

Enum variant count

Crates.io Docs

This crate provides the VariantCount derive macro, which adds to an enum a VARIANT_COUNT constant holding the number of its variants.

The VariantCount usage example:

#[derive(VariantCount)]
enum Test {
    First(i32),
    Second(Option<String>),
    Third,
}

assert_eq!(Test::VARIANT_COUNT, 3);

Usage

If you're using Cargo, just add it to your Cargo.toml:

[dependencies]
variant_count = "1.2"

License

Licensed under either of

at your option.