I think you are overestimating what derive is capable of. Sofar as I know, it doesn’t have any access to type information at all; it’s just like a macro.
Besides, who needs compiler support when you have a deranged madman at hand?
#[macro_use] extern crate custom_derive;
#[macro_use] extern crate newtype_derive;
custom_derive! {
#[derive(Copy, Clone, Eq, PartialEq, Debug,
NewtypeAdd, NewtypeAdd(ref),
NewtypeBitAnd, NewtypeBitAnd(ref),
NewtypeBitOr, NewtypeBitOr(ref),
NewtypeBitXor, NewtypeBitXor(ref),
NewtypeDiv, NewtypeDiv(ref),
NewtypeMul, NewtypeMul(ref),
NewtypeRem, NewtypeRem(ref),
NewtypeSub, NewtypeSub(ref),
NewtypeFrom)]
pub struct Wrapper(i32);
}
// Wrapper now has all those arithmetic ops, plus two-way
// From impls.
(custom_derive is up on crates.io, but you’ll have to grab newtype_derive from Github as it’s still a WIP.)
Edit: I should probably note that the above doesn’t work if you try to derive all arithmetic operators for all existing overloads… you kinda crash face-first into the macro recursion limit. -cough- I might be pushing macro_rules! a bit outside of its comfort zone… into a pit of rabid wolves. That are on fire. And when they bark they shoot bees. Which are also on fire.