Generate enums with matching variants, but without any of the associated data.
enum-kinds-traits
crate contains trait definitions used by this crate.
In other words, enum-kinds-macros
automatically generates enum
s that have
the same set of variants as the original enum
, but with all the embedded data
stripped away (that is, all the variants are unit variants). Additionally,
enum-kinds-macros
implements ToKind
trait for the original enum
allowing
one to get the associated unit variant.
The crates are compatible with stable Rust releases.
```rust
extern crate enumkindsmacros; extern crate enumkindstraits;
use enumkindstraits::ToKind;
enum SomeEnum { First(String, u32), Second(char), Third }
fn testenumkind() { let first = SomeEnum::First("Example".toowned(), 32); asserteq!(first.kind(), SomeEnumKind::First); } ```
The #[derive(EnumKind)]
attribute automatically creates another enum
named
SomeEnumKind
that contains matching unit variants for each of the variants in
SomeEnum
. Additionally, SomeEnum
implements ToKind
trait that provides the
kind
method for constructing matching values from SomeEnumKind
.
While the crates are fairly simple, issues are still possible. If you encounter any problems using these crates, please report them at the issue tracker.
The crates are available under the terms of MIT license.