JelteF/derive_more

Converge my crate into yours

wiiznokes opened this issue · 2 comments

Hi, this is my crate: https://crates.io/crates/light_enum.

Are you interested in a pull request that adds its 2 Derive keywords (LightEnum and Values) ?
Values could be renamed into Array.

I wrote it without thinking that there were already crate for it. Doing this with the derive_more helper functions will be easier I think. And I know there is also EnumDiscriminants from strum.

What do you think?

JelteF commented

I'm not opposed to adding more derives to this crate. But they should have a utility that's not already provided by the other derives or by normal Rust constructs (or at least provide that utility in a easier to use way).

The examples in your crate its README seem already covered:

  • The LightEnum example could trivially be rewritten using the IsVariant derive that's already part of derive_more
  • The Values derive example is so abstract that I don't really understand what it's practical usage is in actual code. i.e. what do you do with an array containing all variants of an enum?

To be clear it's not to say that these are not useful derives, just that based on the README I don't understand what it is.

The LightEnum example could trivially be rewritten using the IsVariant derive that's already part of derive_more

I'm not so sure about that. light_enum provide a way to have a representation of an enum variant.
An usecase for it could be a fonction that generate a enum variant given his Light representation.

The Values derive example is so abstract that I don't really understand what it's practical usage is in actual code. i.e. what do you do with an array containing all variants of an enum?

This is basically the same as EnumIter, but, from my little understanding of Rust, more optimize if you know you will use it in your program, and if your enum will not be very huge (and also if you know you will iter over ALL posible variant of your enum).
But my implementation is not perfect, because it don't use Default::default() like EnumIter (but it could be).