address: Add `Address::into_unchecked`
Adds an ergonomic way to convert any `Address` (network can be checked or unchecked) into an `Address<NetworkUnchecked>` without cloning, which I've found useful in several contexts.
This commit is contained in:
parent
c47a41a076
commit
e4cf8ebc20
|
@ -383,6 +383,9 @@ impl<V: NetworkValidation> Address<V> {
|
||||||
pub fn as_unchecked(&self) -> &Address<NetworkUnchecked> {
|
pub fn as_unchecked(&self) -> &Address<NetworkUnchecked> {
|
||||||
unsafe { &*(self as *const Address<V> as *const Address<NetworkUnchecked>) }
|
unsafe { &*(self as *const Address<V> as *const Address<NetworkUnchecked>) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Marks the network of this address as unchecked.
|
||||||
|
pub fn into_unchecked(self) -> Address<NetworkUnchecked> { Address(self.0, PhantomData) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Methods and functions that can be called only on `Address<NetworkChecked>`.
|
/// Methods and functions that can be called only on `Address<NetworkChecked>`.
|
||||||
|
|
Loading…
Reference in New Issue