From 94f9bac6aadec17bbda66f7ad23a970fccdd840e Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 4 Feb 2025 09:17:59 +1100 Subject: [PATCH] Return Self::Output from ops::Rem The ops traits return `Self::Output` not `Self`. The current code builds because `Self` and `Self::Output` are both the same type. Use `Self::Output` as the return value of `ops::Rem`. --- units/src/amount/signed.rs | 2 +- units/src/amount/unsigned.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/units/src/amount/signed.rs b/units/src/amount/signed.rs index aece125bd..99602eca9 100644 --- a/units/src/amount/signed.rs +++ b/units/src/amount/signed.rs @@ -502,7 +502,7 @@ crate::internal_macros::impl_sub_assign!(SignedAmount); impl ops::Rem for SignedAmount { type Output = SignedAmount; - fn rem(self, modulus: i64) -> Self { + fn rem(self, modulus: i64) -> Self::Output { self.checked_rem(modulus).expect("SignedAmount remainder error") } } diff --git a/units/src/amount/unsigned.rs b/units/src/amount/unsigned.rs index e80f5c6b7..645dbe9d8 100644 --- a/units/src/amount/unsigned.rs +++ b/units/src/amount/unsigned.rs @@ -445,7 +445,7 @@ crate::internal_macros::impl_sub_assign!(Amount); impl ops::Rem for Amount { type Output = Amount; - fn rem(self, modulus: u64) -> Self { + fn rem(self, modulus: u64) -> Self::Output { self.checked_rem(modulus).expect("Amount remainder error") } }