From 43ef9a618c6bc94d2d9e291d92e013b946e3b72d Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 11 Dec 2024 16:31:03 +1100 Subject: [PATCH] units: Implement ops for Weight Use the shiny new ops macros to implement the full set of `Add`, `AddAssign`, `Sub`, and `SubAssign` impls we require. --- units/src/weight.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/units/src/weight.rs b/units/src/weight.rs index 717b3813b..4191c18ea 100644 --- a/units/src/weight.rs +++ b/units/src/weight.rs @@ -171,20 +171,16 @@ impl ops::Add for Weight { fn add(self, rhs: Weight) -> Self::Output { Weight(self.0 + rhs.0) } } - -impl ops::AddAssign for Weight { - fn add_assign(&mut self, rhs: Self) { self.0 += rhs.0 } -} +crate::internal_macros::impl_add_for_references!(Weight); +crate::internal_macros::impl_add_assign!(Weight); impl ops::Sub for Weight { type Output = Weight; fn sub(self, rhs: Weight) -> Self::Output { Weight(self.0 - rhs.0) } } - -impl ops::SubAssign for Weight { - fn sub_assign(&mut self, rhs: Self) { self.0 -= rhs.0 } -} +crate::internal_macros::impl_sub_for_references!(Weight); +crate::internal_macros::impl_sub_assign!(Weight); impl ops::Mul for Weight { type Output = Weight;