From e4cf8ebc208068ef2888e6e9e6f27f12cd07570f Mon Sep 17 00:00:00 2001 From: Max Fang Date: Mon, 18 Nov 2024 17:46:35 -0800 Subject: [PATCH] address: Add `Address::into_unchecked` Adds an ergonomic way to convert any `Address` (network can be checked or unchecked) into an `Address` without cloning, which I've found useful in several contexts. --- bitcoin/src/address/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bitcoin/src/address/mod.rs b/bitcoin/src/address/mod.rs index c7053f667..cc948ad1e 100644 --- a/bitcoin/src/address/mod.rs +++ b/bitcoin/src/address/mod.rs @@ -383,6 +383,9 @@ impl Address { pub fn as_unchecked(&self) -> &Address { unsafe { &*(self as *const Address as *const Address) } } + + /// Marks the network of this address as unchecked. + pub fn into_unchecked(self) -> Address { Address(self.0, PhantomData) } } /// Methods and functions that can be called only on `Address`.