diff --git a/units/src/amount/result.rs b/units/src/amount/result.rs index 4d052ff6b..98ad8df4f 100644 --- a/units/src/amount/result.rs +++ b/units/src/amount/result.rs @@ -137,18 +137,6 @@ crate::internal_macros::impl_op_for_references! { } } -// FIXME these two should be covered by generic impls below -impl ops::Add for NumOpResult { - type Output = NumOpResult; - - fn add(self, rhs: Amount) -> Self::Output { rhs + self } -} -impl ops::Add<&Amount> for NumOpResult { - type Output = NumOpResult; - - fn add(self, rhs: &Amount) -> Self::Output { rhs + self } -} - crate::internal_macros::impl_op_for_references! { impl ops::Sub for Amount { type Output = NumOpResult; @@ -261,7 +249,19 @@ impl ops::Rem<&u64> for &Amount { fn rem(self, modulus: &u64) -> Self::Output { (*self).rem(*modulus) } } -impl ops::Add for SignedAmount { +// FIXME these two should be covered by generic impls below +impl ops::Add for NumOpResult { + type Output = NumOpResult; + + fn add(self, rhs: Amount) -> Self::Output { rhs + self } +} +impl ops::Add<&Amount> for NumOpResult { + type Output = NumOpResult; + + fn add(self, rhs: &Amount) -> Self::Output { rhs + self } +} + +impl ops::Add for SignedAmount { type Output = NumOpResult; fn add(self, rhs: SignedAmount) -> Self::Output { self.checked_add(rhs).valid_or_error() } @@ -289,7 +289,7 @@ impl ops::Add<&SignedAmount> for NumOpResult { fn add(self, rhs: &SignedAmount) -> Self::Output { rhs + self } } -impl ops::Sub for SignedAmount { +impl ops::Sub for SignedAmount { type Output = NumOpResult; fn sub(self, rhs: SignedAmount) -> Self::Output { self.checked_sub(rhs).valid_or_error() } diff --git a/units/src/fee_rate/mod.rs b/units/src/fee_rate/mod.rs index f9dca7b87..1579578cc 100644 --- a/units/src/fee_rate/mod.rs +++ b/units/src/fee_rate/mod.rs @@ -135,20 +135,20 @@ impl From for u64 { fn from(value: FeeRate) -> Self { value.to_sat_per_kwu() } } -impl ops::Add for FeeRate { +impl ops::Add for FeeRate { type Output = FeeRate; fn add(self, rhs: FeeRate) -> Self::Output { FeeRate(self.0 + rhs.0) } } crate::internal_macros::impl_add_for_references!(FeeRate); -crate::internal_macros::impl_add_assign!(FeeRate); -impl ops::Sub for FeeRate { +impl ops::Sub for FeeRate { type Output = FeeRate; fn sub(self, rhs: FeeRate) -> Self::Output { FeeRate(self.0 - rhs.0) } } crate::internal_macros::impl_sub_for_references!(FeeRate); +crate::internal_macros::impl_add_assign!(FeeRate); crate::internal_macros::impl_sub_assign!(FeeRate); impl core::iter::Sum for FeeRate { diff --git a/units/src/weight.rs b/units/src/weight.rs index df654e9d4..a1ea4fa80 100644 --- a/units/src/weight.rs +++ b/units/src/weight.rs @@ -166,20 +166,20 @@ impl From for u64 { fn from(value: Weight) -> Self { value.to_wu() } } -impl ops::Add for Weight { +impl ops::Add for Weight { type Output = Weight; fn add(self, rhs: Weight) -> Self::Output { Weight(self.0 + rhs.0) } } crate::internal_macros::impl_add_for_references!(Weight); -crate::internal_macros::impl_add_assign!(Weight); -impl ops::Sub for Weight { +impl ops::Sub for Weight { type Output = Weight; fn sub(self, rhs: Weight) -> Self::Output { Weight(self.0 - rhs.0) } } crate::internal_macros::impl_sub_for_references!(Weight); +crate::internal_macros::impl_add_assign!(Weight); crate::internal_macros::impl_sub_assign!(Weight); impl ops::Mul for Weight {