Merge rust-bitcoin/rust-bitcoin#3951: Improve examples on `Denomination`

5f75bfaa63 Improve examples on Denomination (Tobin C. Harding)

Pull request description:

  Reduce the noise in the examples.

ACKs for top commit:
  apoelstra:
    ACK 5f75bfaa63309c7526136d430ca8092197ab7c8e; successfully ran local tests; yeah, agreed, this is nicer to read

Tree-SHA512: 01c5863f8712a8ca3b38d3f96be9d08078ca28d8cfc3dd8e8528c388e5f82406a0d43def552b7b53f034c9bf440f7d2d0fec6a760cf69a245b109d0ce4e288c3
This commit is contained in:
merge-script 2025-01-26 16:50:08 +00:00
commit 571402657d
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 14 additions and 6 deletions

View File

@ -58,12 +58,20 @@ pub use self::{
/// ```
/// # use bitcoin_units::Amount;
///
/// assert_eq!("1 BTC".parse::<Amount>().unwrap(), Amount::from_sat(100_000_000));
/// assert_eq!("1 cBTC".parse::<Amount>().unwrap(), Amount::from_sat(1_000_000));
/// assert_eq!("1 mBTC".parse::<Amount>().unwrap(), Amount::from_sat(100_000));
/// assert_eq!("1 uBTC".parse::<Amount>().unwrap(), Amount::from_sat(100));
/// assert_eq!("1 bit".parse::<Amount>().unwrap(), Amount::from_sat(100));
/// assert_eq!("1 sat".parse::<Amount>().unwrap(), Amount::from_sat(1));
/// let equal = [
/// ("1 BTC", 100_000_000),
/// ("1 cBTC", 1_000_000),
/// ("1 mBTC", 100_000),
/// ("1 uBTC", 100),
/// ("1 bit", 100),
/// ("1 sat", 1),
/// ];
/// for (string, sats) in equal {
/// assert_eq!(
/// string.parse::<Amount>().expect("valid bitcoin amount string"),
/// Amount::from_sat(sats),
/// )
/// }
/// ```
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
#[non_exhaustive]