pub trait Xint {
fn wrapping_add(self, other: Self) -> Self;
}
#[macro_export]
macro_rules! impl_xint_wrap {
($name:ident, $uint:ty, $sint:ty) => {
#[derive(Clone, Copy, Default, PartialEq, Eq)]
pub struct $name(pub $uint);
impl Xint for $name {
fn wrapping_add(self, other: Self) -> Self {
Self(self.0.wrapping_add(other.0))
}
}
};
}
impl_xint_wrap!(X8, u8, i8);
impl_xint_wrap!(X16, u16, i16);
impl_xint_wrap!(X32, u32, i32);
impl_xint_wrap!(X64, u64, i64);