1pub use crate::algebra::traits::*;
3use crate::impl_algebra;
4
5#[derive(Clone, Copy, Default, Debug, PartialEq, Eq)]
7pub struct Sum<T>(pub T);
8
9macro_rules! implement {
10 (signed; $($t:ty),*) => {
11 $(impl_algebra!(Sum<$t>; op: |a: Self, b: Self| Self(a.0 + b.0); id: Self(0 as $t); inv: |a: Self| Self(-a.0); commu; assoc;);)*
12 };
13 (unsigned; $($t:ty),*) => {
14 $(impl_algebra!(Sum<$t>; op: |a: Self, b: Self| Self(a.0 + b.0); id: Self(0 as $t); commu; assoc;);)*
15 };
16}
17
18implement!(signed; i8, i16, i32, i64, i128, isize, f32, f64);
19implement!(unsigned; u8, u16, u32, u64, u128, usize);