Enum_from procedural macros

Hi all,

I wrote 2 procedural macros from automating creation of unit-only enums from &str and u64: enum_from.

I was wondering whether it should be an opportunity for a new crate. I know lots of crates has been created for managing enums, I skimmed over those crates but didn't find something really similar and simple.

I also added comments in the code for proc macro newbies.

Comments welcome :wink:

This is basically a subset of strum::EnumString and strum::FromRepr.

2 Likes

@H2CO3 Thanks for your answer. I saw this but I found it overkill for my needs. But definitely an option.

The big dependencies of any procedural macro are syn and quote, so at this point, it probably doesn't matter in terms of compilation time whether you roll your own or use strum. And because of this, it's likely better to use a battle-tested crate than to reinvent the wheel.

3 Likes

Thanks for your comment, but I'm totally aware of that. My intent was not to "reinvent the wheel" as you wrote. That's exactly why I didn't want to publish a new crate after looking closely at strum.

I'm not a newbie in programming (I started my IT professional and developer career in the 90's). So code reuse is not an unknown concept to me :wink: .

I just created my own package to progress in my expertise of writing proc macros.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.