address: Simplify `Address::assume_checked` impl

Removes an unnecessary `match`.
This commit is contained in:
Max Fang 2024-11-18 17:52:11 -08:00
parent e4cf8ebc20
commit 073ff81536
1 changed files with 1 additions and 10 deletions

View File

@ -795,16 +795,7 @@ impl Address<NetworkUnchecked> {
/// For details about this mechanism, see section [*Parsing addresses*](Address#parsing-addresses) /// For details about this mechanism, see section [*Parsing addresses*](Address#parsing-addresses)
/// on [`Address`]. /// on [`Address`].
#[inline] #[inline]
pub fn assume_checked(self) -> Address { pub fn assume_checked(self) -> Address { Address(self.0, PhantomData) }
use AddressInner::*;
let inner = match self.0 {
P2pkh { hash, network } => P2pkh { hash, network },
P2sh { hash, network } => P2sh { hash, network },
Segwit { program, hrp } => Segwit { program, hrp },
};
Address(inner, PhantomData)
}
/// Parse a bech32 Address string /// Parse a bech32 Address string
pub fn from_bech32_str(s: &str) -> Result<Address<NetworkUnchecked>, Bech32Error> { pub fn from_bech32_str(s: &str) -> Result<Address<NetworkUnchecked>, Bech32Error> {