num-traits
num-traits copied to clipboard
Introduce derive macros
I think it would be quite neat to have derive macros for all num-traits and this shouldn't be breaking.
Use cases would mostly to write simple wrappers as such to make trait implementations easier down the line, but there could be other benefits from this as well:
#[derive(Float, FloatCore)
struct Float<F>(F) where F: Float + FloatCore;
#[derive(PrimInt)
struct Integer<I>(I) where F: PrimInt;
trait Foo{}
//not necessary to implement f32, f64 directly
impl<F> Foo for Float<F>{}
//same here for u8, i8, u16, ...
impl<I> Foo for Integer<I>{}
We do have num-derive, but not for generic types, as there are some open questions: https://github.com/rust-num/num-derive/pull/37