Let's say I have defined a Group trait with all the group operations. Would it be possible to create a wrapper AGroup over Group without having to manually derive all its operations?
Basically, I'd like to have this:
#[derive (Copy, Debug, Clone, Eq, PartialEq, Group)] // How could I derive Group here as well?
struct AGroup<G: Group>(G);
without all this boilerplate:
impl<G: Group> Add for AGroup<G>{
type Output = AGroup<G>;
fn add(self, other: Self) -> Self {
AGroup(self.0 + other.0)
}
}
impl<G: Group> Neg for AGroup<G>{
type Output = AGroup<G>;
fn neg(self) -> Self {
AGroup(-self.0)
}
}
...
Group's to always return anAGroup?Grouplooks something liketrait Group: Add<Output=Self> + Neg<Output = Self> + ... {}(to make the boilerplate make sense). If that is so, please add that to the answer; ifGroupis substantially different from that, please indicate how, so I can make sure my answer is correct. Thanks!