Skip to content

XX/variant_count

Repository files navigation

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.

About

Derive macro that adds a variant count to an enum.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

13 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages