lloydmeta / frunk

Funktional generic type-level programming in Rust: HList, Coproduct, Generic, LabelledGeneric, Validated, Monoid and friends.
https://beachape.com/frunk/
MIT License
1.28k stars 58 forks source link

Refactor derives #157

Closed Diggsey closed 5 years ago

Diggsey commented 5 years ago

This should make it much easier to extend these derives to support enums.

The only change to behaviour should be that LabelledGeneric can now be derived on unit structs.

Changes to the generated code:

Changes to naming conventions:

There are several features that could be added as follow-ups to this PR:

Are these features you would want to add?

lloydmeta commented 5 years ago

Thanks so much for doing this. Indeed, this area of the code has been needing some additional love for a while, exactly for the reasons you cited (better readability, extendability)

There are several features that could be added as follow-ups to this PR:

  • Addition of IntoGeneric trait and implementation of Generic for references to types deriving Generic.
  • Support for deriving Generic and LabelledGeneric on enums.

Are these features you would want to add?

Most definitely, those would be amazing to have. If I was a prioritising man, I would say the deriving LabelledGeneric for enums would probably be on the top of that list :)

Also, sorry for the delayed response; I'm currently on vacation and will take a closer look when I'm back and settled in. Looking awesome thus far !

Diggsey commented 5 years ago

I've added a rustfmt commit.