Merge rust-bitcoin/rust-bitcoin#1539: Add a rustdoc test to Denomination

a7dd4b5ab0 Add a rustdoc test to Denomination (Tobin C. Harding)

Pull request description:

  Add a rustdoc test to the `Denomination` type to show basic usage.

ACKs for top commit:
  Kixunil:
    ACK a7dd4b5ab0
  apoelstra:
    ACK a7dd4b5ab0

Tree-SHA512: 08f15c4641e70f043276b873e60fcf0e195fe50b6c5c18a245d2d609f4a4a4badc291aae1be532fc4890a91b2057cd308c86d0d3b85770b600a07499303a7bc4
This commit is contained in:
Andrew Poelstra 2023-01-15 22:52:43 +00:00
commit 006fe3c223
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 15 additions and 0 deletions

View File

@ -14,6 +14,21 @@ use core::{default, ops};
use crate::prelude::*; use crate::prelude::*;
/// A set of denominations in which amounts can be expressed. /// A set of denominations in which amounts can be expressed.
///
/// # Examples
/// ```
/// # use core::str::FromStr;
/// # use bitcoin::Amount;
///
/// assert_eq!(Amount::from_str("1 BTC").unwrap(), Amount::from_sat(100_000_000));
/// assert_eq!(Amount::from_str("1 mBTC").unwrap(), Amount::from_sat(100_000));
/// assert_eq!(Amount::from_str("1 uBTC").unwrap(), Amount::from_sat(100));
/// assert_eq!(Amount::from_str("10 nBTC").unwrap(), Amount::from_sat(1));
/// assert_eq!(Amount::from_str("10000 pBTC").unwrap(), Amount::from_sat(1));
/// assert_eq!(Amount::from_str("1 bit").unwrap(), Amount::from_sat(100));
/// assert_eq!(Amount::from_str("1 sat").unwrap(), Amount::from_sat(1));
/// assert_eq!(Amount::from_str("1000 msats").unwrap(), Amount::from_sat(1));
/// ```
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
pub enum Denomination { pub enum Denomination {
/// BTC /// BTC