From 5d851f1c3e98d7d426e5897b2d734b77a299ccfb Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 28 Feb 2025 13:02:38 +1100 Subject: [PATCH] Remove deprecated amount methods When we enforce the MAX_MONEY invariant these functions would require the function signature changing - might as well just delete them. --- units/src/amount/signed.rs | 26 -------------------------- units/src/amount/tests.rs | 9 --------- units/src/amount/unsigned.rs | 26 -------------------------- 3 files changed, 61 deletions(-) diff --git a/units/src/amount/signed.rs b/units/src/amount/signed.rs index df9aa18f3..a04795de6 100644 --- a/units/src/amount/signed.rs +++ b/units/src/amount/signed.rs @@ -402,32 +402,6 @@ impl SignedAmount { } } - /// Unchecked addition. - /// - /// Computes `self + rhs`. - /// - /// # Panics - /// - /// On overflow, panics in debug mode, wraps in release mode. - #[must_use] - #[deprecated(since = "TBD", note = "consider converting to u64 using `to_sat`")] - pub fn unchecked_add(self, rhs: SignedAmount) -> SignedAmount { - Self::from_sat(self.to_sat() + rhs.to_sat()) - } - - /// Unchecked subtraction. - /// - /// Computes `self - rhs`. - /// - /// # Panics - /// - /// On overflow, panics in debug mode, wraps in release mode. - #[must_use] - #[deprecated(since = "TBD", note = "consider converting to u64 using `to_sat`")] - pub fn unchecked_sub(self, rhs: SignedAmount) -> SignedAmount { - Self::from_sat(self.to_sat() - rhs.to_sat()) - } - /// Subtraction that doesn't allow negative [`SignedAmount`]s. /// /// Returns [`None`] if either `self`, `rhs` or the result is strictly negative. diff --git a/units/src/amount/tests.rs b/units/src/amount/tests.rs index a692ca650..2d3b5e1c6 100644 --- a/units/src/amount/tests.rs +++ b/units/src/amount/tests.rs @@ -180,15 +180,6 @@ fn checked_arithmetic() { assert_eq!(ssat(-6).checked_div(2), Some(ssat(-3))); } -#[test] -#[allow(deprecated_in_future)] -fn unchecked_arithmetic() { - assert_eq!(ssat(10).unchecked_add(ssat(20)), ssat(30)); - assert_eq!(ssat(50).unchecked_sub(ssat(10)), ssat(40)); - assert_eq!(sat(5).unchecked_add(sat(7)), sat(12)); - assert_eq!(sat(10).unchecked_sub(sat(7)), sat(3)); -} - #[test] fn positive_sub() { assert_eq!(ssat(10).positive_sub(ssat(7)).unwrap(), ssat(3)); diff --git a/units/src/amount/unsigned.rs b/units/src/amount/unsigned.rs index 167ad85f3..c3488dfaf 100644 --- a/units/src/amount/unsigned.rs +++ b/units/src/amount/unsigned.rs @@ -358,32 +358,6 @@ impl Amount { } } - /// Unchecked addition. - /// - /// Computes `self + rhs`. - /// - /// # Panics - /// - /// On overflow, panics in debug mode, wraps in release mode. - #[must_use] - #[deprecated(since = "TBD", note = "consider converting to u64 using `to_sat`")] - pub fn unchecked_add(self, rhs: Amount) -> Amount { - Self::from_sat(self.to_sat() + rhs.to_sat()) - } - - /// Unchecked subtraction. - /// - /// Computes `self - rhs`. - /// - /// # Panics - /// - /// On overflow, panics in debug mode, wraps in release mode. - #[must_use] - #[deprecated(since = "TBD", note = "consider converting to u64 using `to_sat`")] - pub fn unchecked_sub(self, rhs: Amount) -> Amount { - Self::from_sat(self.to_sat() - rhs.to_sat()) - } - /// Converts to a signed amount. #[rustfmt::skip] // Moves code comments to the wrong line. pub fn to_signed(self) -> SignedAmount {