Implement Rem for Weight

`Weight` implements `Div` but not `Rem`

Add `Rem` impl for `Weight`
This commit is contained in:
Jamil Lambert, PhD 2025-03-03 17:36:26 +00:00
parent 72823df014
commit 4787aa1f89
No known key found for this signature in database
GPG Key ID: 54DC29234AB5D2C0
1 changed files with 14 additions and 0 deletions

View File

@ -198,6 +198,16 @@ crate::internal_macros::impl_op_for_references! {
fn div(self, rhs: Weight) -> Self::Output { self.to_wu() / rhs.to_wu() }
}
impl ops::Rem<u64> for Weight {
type Output = Weight;
fn rem(self, rhs: u64) -> Self::Output { Weight(self.0 % rhs) }
}
impl ops::Rem<Weight> for Weight {
type Output = u64;
fn rem(self, rhs: Weight) -> Self::Output { self.0 % rhs.0 }
}
}
crate::internal_macros::impl_add_assign!(Weight);
crate::internal_macros::impl_sub_assign!(Weight);
@ -210,6 +220,10 @@ impl ops::DivAssign<u64> for Weight {
fn div_assign(&mut self, rhs: u64) { self.0 /= rhs }
}
impl ops::RemAssign<u64> for Weight {
fn rem_assign(&mut self, rhs: u64) { self.0 %= rhs }
}
impl core::iter::Sum for Weight {
fn sum<I>(iter: I) -> Self
where