meithecatte/enumflags2

Generate discriminants

Closed this issue · 1 comments

There doesn't seem to be any specific reason to require discriminants to be manually created. Can this be generated automatically?

I have thought about this before. The issue here is that derive-style macros can't change the code, only add more. This means that an attribute-style macro (#[bitflags]) would be needed.

I can see two ways forward here:

  1. Add the attribute macro alongside the derive macro. Downsides: potentially confusing to users, increased maintenance burden.
  2. Replace the derive macro with an attribute macro. Downsides: breaking change.
    2b. As above, but with a transition period, and perhaps a deprecation warning.

I'll think about this some more.