Add a rustdoc test to Denomination

Add a rustdoc test to the `Denomination` type to show basic usage.
This commit is contained in:
Tobin C. Harding 2023-01-11 08:52:44 +11:00
parent e36ae3a229
commit a7dd4b5ab0
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
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