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.
This commit is contained in:
parent
76a2d70b28
commit
5d851f1c3e
|
@ -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.
|
/// Subtraction that doesn't allow negative [`SignedAmount`]s.
|
||||||
///
|
///
|
||||||
/// Returns [`None`] if either `self`, `rhs` or the result is strictly negative.
|
/// Returns [`None`] if either `self`, `rhs` or the result is strictly negative.
|
||||||
|
|
|
@ -180,15 +180,6 @@ fn checked_arithmetic() {
|
||||||
assert_eq!(ssat(-6).checked_div(2), Some(ssat(-3)));
|
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]
|
#[test]
|
||||||
fn positive_sub() {
|
fn positive_sub() {
|
||||||
assert_eq!(ssat(10).positive_sub(ssat(7)).unwrap(), ssat(3));
|
assert_eq!(ssat(10).positive_sub(ssat(7)).unwrap(), ssat(3));
|
||||||
|
|
|
@ -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.
|
/// Converts to a signed amount.
|
||||||
#[rustfmt::skip] // Moves code comments to the wrong line.
|
#[rustfmt::skip] // Moves code comments to the wrong line.
|
||||||
pub fn to_signed(self) -> SignedAmount {
|
pub fn to_signed(self) -> SignedAmount {
|
||||||
|
|
Loading…
Reference in New Issue