Add rustdoc errors
This commit is contained in:
parent
78f1628bf6
commit
937a3da8dd
|
@ -85,6 +85,12 @@ impl SignedAmount {
|
||||||
|
|
||||||
/// Converts from a value expressing a decimal number of bitcoin to a [`SignedAmount`].
|
/// Converts from a value expressing a decimal number of bitcoin to a [`SignedAmount`].
|
||||||
///
|
///
|
||||||
|
/// # Errors
|
||||||
|
///
|
||||||
|
/// If the amount is too big (positive or negative) or too precise.
|
||||||
|
///
|
||||||
|
/// Please be aware of the risk of using floating-point numbers.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -128,6 +134,10 @@ impl SignedAmount {
|
||||||
///
|
///
|
||||||
/// Note: This only parses the value string. If you want to parse a string
|
/// Note: This only parses the value string. If you want to parse a string
|
||||||
/// containing the value with denomination, use [`FromStr`].
|
/// containing the value with denomination, use [`FromStr`].
|
||||||
|
///
|
||||||
|
/// # Errors
|
||||||
|
///
|
||||||
|
/// If the amount is too big (positive or negative) or too precise.
|
||||||
pub fn from_str_in(s: &str, denom: Denomination) -> Result<SignedAmount, ParseAmountError> {
|
pub fn from_str_in(s: &str, denom: Denomination) -> Result<SignedAmount, ParseAmountError> {
|
||||||
match parse_signed_to_satoshi(s, denom).map_err(|error| error.convert(true))? {
|
match parse_signed_to_satoshi(s, denom).map_err(|error| error.convert(true))? {
|
||||||
// (negative, amount)
|
// (negative, amount)
|
||||||
|
@ -147,6 +157,10 @@ impl SignedAmount {
|
||||||
///
|
///
|
||||||
/// If you want to parse only the amount without the denomination, use [`Self::from_str_in`].
|
/// If you want to parse only the amount without the denomination, use [`Self::from_str_in`].
|
||||||
///
|
///
|
||||||
|
/// # Errors
|
||||||
|
///
|
||||||
|
/// If the amount is too big (positive or negative) or too precise.
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -194,7 +208,7 @@ impl SignedAmount {
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// If the amount is too big, too precise or negative.
|
/// If the amount is too big (positive or negative) or too precise.
|
||||||
///
|
///
|
||||||
/// Please be aware of the risk of using floating-point numbers.
|
/// Please be aware of the risk of using floating-point numbers.
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
@ -417,6 +431,10 @@ impl SignedAmount {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts to an unsigned amount.
|
/// Converts to an unsigned amount.
|
||||||
|
///
|
||||||
|
/// # Errors
|
||||||
|
///
|
||||||
|
/// If the amount is negative.
|
||||||
pub fn to_unsigned(self) -> Result<Amount, OutOfRangeError> {
|
pub fn to_unsigned(self) -> Result<Amount, OutOfRangeError> {
|
||||||
if self.is_negative() {
|
if self.is_negative() {
|
||||||
Err(OutOfRangeError::negative())
|
Err(OutOfRangeError::negative())
|
||||||
|
|
Loading…
Reference in New Issue