Macro alga::impl_ring
[−]
[src]
macro_rules! impl_ring { (<$A:ty, $M:ty> for $($T:tt)+) => { ... }; }
Implements the ring trait for types provided.
Examples
#[derive(PartialEq, Clone)] struct Wrapper<T>(T); impl<T: AbstractMagma<Additive>> AbstractMagma<Additive> for Wrapper<T> { fn operate(&self, right: &Self) -> Self { Wrapper(self.0.operate(&right.0)) } } impl<T: Inverse<Additive>> Inverse<Additive> for Wrapper<T> { fn inverse(&self) -> Self { Wrapper(self.0.inverse()) } } impl<T: Identity<Additive>> Identity<Additive> for Wrapper<T> { fn identity() -> Self { Wrapper(T::identity()) } } impl<T: AbstractMagma<Multiplicative>> AbstractMagma<Multiplicative> for Wrapper<T> { fn operate(&self, right: &Self) -> Self { Wrapper(self.0.operate(&right.0)) } } impl<T: Identity<Multiplicative>> Identity<Multiplicative> for Wrapper<T> { fn identity() -> Self { Wrapper(T::identity()) } } impl_ring!(<Additive, Multiplicative> for Wrapper<T> where T: AbstractRing);