I am trying to define a
stringy_enum! macro that will save me some typing when converting to and from strings:
However, when I call
stringy_enum!(FooBar => [Foo, Bar, Baz]), the compiler complains that
Baz are undefined in this scope. I thought that the hole point of this exercise was to write a macro that defines those symbols, but apparently I am missing something.
My question is two fold:
- How to define a symbol (in this case an
- Is there a more idiomatic way to define an
enumthat can parse and display itself, e.g.
"Foo" -> Foobar::Fooand
Foobar::Foo -> "Foo"?
edit: fixed playground link