amount: remove from_sat_unchecked
Turns out we don't even need this. It is only used in one place now and we can just stick an .expect there.
This commit is contained in:
parent
d0d7a15604
commit
2958521117
|
@ -57,13 +57,6 @@ mod encapsulate {
|
||||||
/// The minimum value of an amount.
|
/// The minimum value of an amount.
|
||||||
pub const MIN: Self = Self(-21_000_000 * 100_000_000);
|
pub const MIN: Self = Self(-21_000_000 * 100_000_000);
|
||||||
|
|
||||||
/// Constructs a new [`SignedAmount`] with satoshi precision and the given number of satoshis.
|
|
||||||
///
|
|
||||||
/// Caller to guarantee that `satoshi` is within valid range.
|
|
||||||
///
|
|
||||||
/// See [`Self::MIN`] and [`Self::MAX`].
|
|
||||||
pub const fn from_sat_unchecked(satoshi: i64) -> SignedAmount { SignedAmount(satoshi) }
|
|
||||||
|
|
||||||
/// Constructs a new [`SignedAmount`] with satoshi precision and the given number of satoshis.
|
/// Constructs a new [`SignedAmount`] with satoshi precision and the given number of satoshis.
|
||||||
///
|
///
|
||||||
/// Accepts an `i32` which is guaranteed to be in range for the type, but which can only
|
/// Accepts an `i32` which is guaranteed to be in range for the type, but which can only
|
||||||
|
|
|
@ -57,11 +57,6 @@ mod encapsulate {
|
||||||
/// The minimum value of an amount.
|
/// The minimum value of an amount.
|
||||||
pub const MIN: Self = Self(0);
|
pub const MIN: Self = Self(0);
|
||||||
|
|
||||||
/// Constructs a new [`Amount`] with satoshi precision and the given number of satoshis.
|
|
||||||
///
|
|
||||||
/// Caller to guarantee that `satoshi` is within valid range. See [`Self::MAX`].
|
|
||||||
pub const fn from_sat_unchecked(satoshi: u64) -> Amount { Self(satoshi) }
|
|
||||||
|
|
||||||
/// Constructs a new [`Amount`] with satoshi precision and the given number of satoshis.
|
/// Constructs a new [`Amount`] with satoshi precision and the given number of satoshis.
|
||||||
///
|
///
|
||||||
/// Accepts an `u32` which is guaranteed to be in range for the type, but which can only
|
/// Accepts an `u32` which is guaranteed to be in range for the type, but which can only
|
||||||
|
@ -398,8 +393,10 @@ impl Amount {
|
||||||
|
|
||||||
/// 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.
|
||||||
|
#[allow(clippy::missing_panics_doc)]
|
||||||
pub fn to_signed(self) -> SignedAmount {
|
pub fn to_signed(self) -> SignedAmount {
|
||||||
SignedAmount::from_sat_unchecked(self.to_sat() as i64) // Cast ok, signed amount and amount share positive range.
|
SignedAmount::from_sat(self.to_sat() as i64) // Cast ok, signed amount and amount share positive range.
|
||||||
|
.expect("range of Amount is within range of SignedAmount")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue