enum-assoc: A crate to associate constants with enum variants
I made this crate to solve a particular problem, eg:
enum SomeEnum
{
Var1,
// ... lots more variants
}
impl Some Enum
{
fn some_associated_constants() -> u8
{
Self::Var1 => 77,
// ... lots more associations
}
// ... lots more functions that re-list every variant
}
I wanted some way to do this without re-listing every variant over and over, so I could instead have all the data in one place. Procedural macros ended up being a pretty good way to do this, so I'm releasing this one I made. It's relatively simple, and to be honest I'm surprised I couldn't find something that did this already... maybe it's out there somewhere. Otherwise, I think this is a pretty reasonable solution. Details on what it does are in the link I posted above.