Skip to content

Derive macro for enum which adds to it the count of variants.

License

Notifications You must be signed in to change notification settings

XX/variant_count

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.2"

License

MIT

About

Derive macro for enum which adds to it the count of variants.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages