Lolirofle / enum_traits

Simple traits and derives for enums in the Rust programming language
MIT License
6 stars 5 forks source link

Derive Enum Kind #5

Open CryZe opened 7 years ago

CryZe commented 7 years ago

Often it makes sense to have a separate enum that contains the same variants, but without their associated data. This is often useful for error types, but also useful for a lot of other situations. So the derive would create a second type with the exact same variations named <EnumName>Kind deriving PartialEq, Eq, Debug and potentially other traits. And the original enum would get a method fn kind(&self) -> <EnumName>Kind that returns that kind.