DanielKeep / rust-custom-derive

Custom derivation macro for Rust
Other
110 stars 17 forks source link

NewtypeZero and NewtypeOrd macros #4

Closed agrover closed 8 years ago

agrover commented 8 years ago

I'm finding I need to implement Zero, so I can call sum() on an iterator of T.

I'm also finding I need to implement Ord in order to sort a vec of T.

Could both of these have macros to derive their implementations?

agrover commented 8 years ago

oops, wrong repo.

agrover commented 8 years ago

nope, right repo after all :-)

DanielKeep commented 8 years ago

Zero is an unstable trait, so it would probably have to go behind a feature gate. It's a shame we can't gate code based on individual language features...

Ord, on the other hand, can already be derived directly. How is the standard compiler support not sufficient?

agrover commented 8 years ago

Hah, yes, Ord derives fine, error on my part.

DanielKeep commented 8 years ago

In that case, I'll close this since I added macros for One and Zero. Since they're unstable, they're behind a feature flag.