diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs index 3a41f461b..90b928194 100644 --- a/bitcoin/src/bip32.rs +++ b/bitcoin/src/bip32.rs @@ -421,11 +421,10 @@ impl DerivationPath { /// /// ``` /// use bitcoin::bip32::{DerivationPath, ChildNumber}; - /// use std::str::FromStr; /// - /// let base = DerivationPath::from_str("m/42").unwrap(); + /// let base = "m/42".parse::().unwrap(); /// - /// let deriv_1 = base.extend(DerivationPath::from_str("0/1").unwrap()); + /// let deriv_1 = base.extend("0/1".parse::().unwrap()); /// let deriv_2 = base.extend(&[ /// ChildNumber::ZERO_NORMAL, /// ChildNumber::ONE_NORMAL @@ -447,7 +446,7 @@ impl DerivationPath { /// use bitcoin::bip32::DerivationPath; /// use std::str::FromStr; /// - /// let path = DerivationPath::from_str("m/84'/0'/0'/0/1").unwrap(); + /// let path = "m/84'/0'/0'/0/1".parse::().unwrap(); /// const HARDENED: u32 = 0x80000000; /// assert_eq!(path.to_u32_vec(), vec![84 + HARDENED, HARDENED, HARDENED, 0, 1]); /// ``` diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs index e2ab25fca..768919eae 100644 --- a/bitcoin/src/crypto/key.rs +++ b/bitcoin/src/crypto/key.rs @@ -134,10 +134,9 @@ impl PublicKey { /// # Example: Using with `sort_unstable_by_key` /// /// ```rust - /// use std::str::FromStr; /// use bitcoin::PublicKey; /// - /// let pk = |s| PublicKey::from_str(s).unwrap(); + /// let pk = |s: &str| s.parse::().unwrap(); /// /// let mut unsorted = [ /// pk("04c4b0bbb339aa236bff38dbe6a451e111972a7909a126bc424013cba2ec33bc38e98ac269ffe028345c31ac8d0a365f29c8f7e7cfccac72f84e1acd02bc554f35"), diff --git a/units/src/amount.rs b/units/src/amount.rs index 9d5118c3b..bc1d402f1 100644 --- a/units/src/amount.rs +++ b/units/src/amount.rs @@ -37,15 +37,14 @@ use arbitrary::{Arbitrary, Unstructured}; /// # Examples /// /// ``` -/// # use core::str::FromStr; /// # use bitcoin_units::Amount; /// -/// assert_eq!(Amount::from_str("1 BTC").unwrap(), Amount::from_sat(100_000_000)); -/// assert_eq!(Amount::from_str("1 cBTC").unwrap(), Amount::from_sat(1_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("1 bit").unwrap(), Amount::from_sat(100)); -/// assert_eq!(Amount::from_str("1 sat").unwrap(), Amount::from_sat(1)); +/// assert_eq!("1 BTC".parse::().unwrap(), Amount::from_sat(100_000_000)); +/// assert_eq!("1 cBTC".parse::().unwrap(), Amount::from_sat(1_000_000)); +/// assert_eq!("1 mBTC".parse::().unwrap(), Amount::from_sat(100_000)); +/// assert_eq!("1 uBTC".parse::().unwrap(), Amount::from_sat(100)); +/// assert_eq!("1 bit".parse::().unwrap(), Amount::from_sat(100)); +/// assert_eq!("1 sat".parse::().unwrap(), Amount::from_sat(1)); /// ``` #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] #[non_exhaustive]