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)
}
}
...