Merge rust-bitcoin/rust-bitcoin#3759: units: Deprecate unchecked ops
b895c9aad4
units: Deprecate unchecked ops (Tobin C. Harding)
Pull request description:
These functions do not add value because one can just call `to_sat` and `from_sat` if doing ops in a tight loop.
Note we need to remove these deprecated functions before we release `units v1.0`.
ACKs for top commit:
apoelstra:
ACK b895c9aad4e56ff7cf5420f71ae501f942a81326; successfully ran local tests
Tree-SHA512: c42a177aa955cbddf523e0acd2385a0cece468ec9c8a0d1fd1cd8ceb085b9fad34c79d52cf2f16d94945bf2ae2f6934fac8e9efc879a649670bc48c20bd0a344
This commit is contained in:
commit
90393a66a1
|
@ -318,6 +318,7 @@ impl SignedAmount {
|
|||
///
|
||||
/// 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(self.0 + rhs.0) }
|
||||
|
||||
/// Unchecked subtraction.
|
||||
|
@ -328,6 +329,7 @@ impl SignedAmount {
|
|||
///
|
||||
/// 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(self.0 - rhs.0) }
|
||||
|
||||
/// Subtraction that doesn't allow negative [`SignedAmount`]s.
|
||||
|
|
|
@ -394,6 +394,7 @@ impl Amount {
|
|||
///
|
||||
/// 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(self.0 + rhs.0) }
|
||||
|
||||
/// Unchecked subtraction.
|
||||
|
@ -404,6 +405,7 @@ impl Amount {
|
|||
///
|
||||
/// 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(self.0 - rhs.0) }
|
||||
|
||||
/// Converts to a signed amount.
|
||||
|
|
Loading…
Reference in New Issue