str_enum
A real simple declarative macro that I have ended up copy pasting into a few of my projects, spruced up with a couple features to make it more flexible.
Unless you're a real stickler for compile times you're probably fine with strum over this for more features.
It implements basically everything str does, minus the derives which are opt-in. So you can probably use this anywhere you use &str.
use str_enum;
str_enum!
Features
| feature | description |
|---|---|
| serde | Enables serde as a dependency and implements Serialize and Deserialize for the enum, respecting alternate valid forms. |
| strum | Enables strum as a dependency and implements EnumCount, IntoDiscriminant (if you have a defined repr), IntoEnumIterator, VariantArray, VariantIterator, VariantNames and VariantMetadata. Note that the IntoDiscriminant implementation requires your enum to opt into implementing Copy |