What changed, and why it matters
This commit is a small type-correctness fix for the Rust Bitcoin library. It changes the result type of the remainder operator (%) when both inputs are Weight values, so the result is a Weight instead of a plain number. This is a normal API cleanup, not a security fix.
No security action needed. Treat as a routine API/type-correctness change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies the Rem
Changed components
units/src/weight.rsWeight type remainder operatorInspect captured patch +3 / −3
diff --git a/units/src/weight.rs b/units/src/weight.rs
index d42d6420..e026e329 100644
--- a/units/src/weight.rs
+++ b/units/src/weight.rs
@@ -233,9 +233,9 @@ crate::internal_macros::impl_op_for_references! {
fn rem(self, rhs: u64) -> Self::Output { Weight::from_wu(self.to_wu() % rhs) }
}
impl ops::Rem<Weight> for Weight {
- type Output = u64;
+ type Output = Weight;
- fn rem(self, rhs: Weight) -> Self::Output { self.to_wu() % rhs.to_wu() }
+ fn rem(self, rhs: Weight) -> Self::Output { Weight::from_wu(self.to_wu() % rhs.to_wu()) }
}
impl ops::Div<NonZeroU64> for Weight {
type Output = Weight;
@@ -550,7 +550,7 @@ mod tests {
let weight3 = Weight::from_wu(3);
let remainder = weight10 % weight3;
- assert_eq!(remainder, 1);
+ assert_eq!(remainder, Weight::from_wu(1));
let remainder = weight10 % 3;
assert_eq!(remainder, Weight::from_wu(1));
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.