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.
This commit is contained in:
Tobin C. Harding 2024-12-11 16:31:03 +11:00
parent c5fbc7e117
commit 43ef9a618c
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 4 additions and 8 deletions

View File

@ -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<u64> for Weight {
type Output = Weight;