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:
commit
571402657d
|
@ -58,12 +58,20 @@ pub use self::{
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bitcoin_units::Amount;
|
/// # use bitcoin_units::Amount;
|
||||||
///
|
///
|
||||||
/// assert_eq!("1 BTC".parse::<Amount>().unwrap(), Amount::from_sat(100_000_000));
|
/// let equal = [
|
||||||
/// assert_eq!("1 cBTC".parse::<Amount>().unwrap(), Amount::from_sat(1_000_000));
|
/// ("1 BTC", 100_000_000),
|
||||||
/// assert_eq!("1 mBTC".parse::<Amount>().unwrap(), Amount::from_sat(100_000));
|
/// ("1 cBTC", 1_000_000),
|
||||||
/// assert_eq!("1 uBTC".parse::<Amount>().unwrap(), Amount::from_sat(100));
|
/// ("1 mBTC", 100_000),
|
||||||
/// assert_eq!("1 bit".parse::<Amount>().unwrap(), Amount::from_sat(100));
|
/// ("1 uBTC", 100),
|
||||||
/// assert_eq!("1 sat".parse::<Amount>().unwrap(), Amount::from_sat(1));
|
/// ("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)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
|
|
Loading…
Reference in New Issue