variant_count

Crates.iovariant_count
lib.rsvariant_count
version1.1.0
sourcesrc
created_at2018-11-01 22:15:41.476219
updated_at2021-04-07 15:48:03.565471
descriptionDerive macro for enum which adds to it the count of variants.
homepage
repositoryhttps://github.com/XX/variant_count
max_upload_size
id94100
size5,489
Alexander Mescheryakov (XX)

documentation

https://docs.rs/variant_count

README

Enum variant count

Crates.io Docs

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);

Usage

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

[dependencies]
variant_count = "1.1"

License

MIT

Commit count: 9

cargo fmt