Crate variant_count[−][src]
This crate provides VariantCount
derive macro for enum which adds to it the VARIANT_COUNT
constant, containing count of enum variants.
Example
extern crate variant_count; use variant_count::VariantCount; #[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.1"
Use VariantCount
in the derive
enum attribute.
Derive Macros
VariantCount |