diff --git a/src/uu/factor/src/numeric.rs b/src/uu/factor/src/numeric.rs index bbfce9f26..b1f929d4b 100644 --- a/src/uu/factor/src/numeric.rs +++ b/src/uu/factor/src/numeric.rs @@ -198,21 +198,18 @@ impl Arithmetic for Montgomery { pub(crate) trait OverflowingAdd: Sized { fn overflowing_add_(self, n: Self) -> (Self, bool); } -impl OverflowingAdd for u32 { - fn overflowing_add_(self, n: Self) -> (Self, bool) { - self.overflowing_add(n) - } -} -impl OverflowingAdd for u64 { - fn overflowing_add_(self, n: Self) -> (Self, bool) { - self.overflowing_add(n) - } -} -impl OverflowingAdd for u128 { - fn overflowing_add_(self, n: Self) -> (Self, bool) { - self.overflowing_add(n) - } +macro_rules! overflowing { + ($x:ty) => { + impl OverflowingAdd for $x { + fn overflowing_add_(self, n: Self) -> (Self, bool) { + self.overflowing_add(n) + } + } + }; } +overflowing!(u32); +overflowing!(u64); +overflowing!(u128); pub(crate) trait Int: Display + Debug + PrimInt + OverflowingAdd + WrappingNeg + WrappingSub + WrappingMul