From a7dd4b5ab061c04ad7a7a81856b27757da87647f Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 11 Jan 2023 08:52:44 +1100 Subject: [PATCH] Add a rustdoc test to Denomination Add a rustdoc test to the `Denomination` type to show basic usage. --- bitcoin/src/amount.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bitcoin/src/amount.rs b/bitcoin/src/amount.rs index 3a7d2d0d..23f9345f 100644 --- a/bitcoin/src/amount.rs +++ b/bitcoin/src/amount.rs @@ -14,6 +14,21 @@ use core::{default, ops}; use crate::prelude::*; /// 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)] pub enum Denomination { /// BTC