Merge rust-bitcoin/rust-bitcoin#2306: Improve address conversion docs
03bfe1d433
Impove rustdoc on assume_checked_ref (Tobin C. Harding)769809f1f2
Improve the docs on as_unchecked function (Tobin C. Harding) Pull request description: In #1765 we added a couple of new functions. - Patch 1: Fix mis-documented function. - Patch 2: Do trivial rustdocs fix. ACKs for top commit: apoelstra: ACK03bfe1d433
Kixunil: ACK03bfe1d433
Tree-SHA512: 5be6b2d288c1f4e9096014acd8618dc84a3ec6f45ae38b5d44ef7f95eccc268021bc8e8435152166606d893d4238b03e59e8f9d4fc67ba9a6c33194f3f54fc40
This commit is contained in:
commit
b63921d625
|
@ -353,8 +353,7 @@ impl<N: NetworkValidation> serde::Serialize for Address<N> {
|
|||
/// Methods on [`Address`] that can be called on both `Address<NetworkChecked>` and
|
||||
/// `Address<NetworkUnchecked>`.
|
||||
impl<V: NetworkValidation> Address<V> {
|
||||
/// Returns a reference to the unchecked address, which is dangerous to use if the address
|
||||
/// is invalid in the context of `NetworkUnchecked`.
|
||||
/// Returns a reference to the address as if it was unchecked.
|
||||
pub fn as_unchecked(&self) -> &Address<NetworkUnchecked> {
|
||||
unsafe { &*(self as *const Address<V> as *const Address<NetworkUnchecked>) }
|
||||
}
|
||||
|
@ -630,10 +629,12 @@ impl Address {
|
|||
/// Methods that can be called only on `Address<NetworkUnchecked>`.
|
||||
impl Address<NetworkUnchecked> {
|
||||
/// Returns a reference to the checked address.
|
||||
///
|
||||
/// This function is dangerous in case the address is not a valid checked address.
|
||||
pub fn assume_checked_ref(&self) -> &Address {
|
||||
unsafe { &*(self as *const Address<NetworkUnchecked> as *const Address) }
|
||||
}
|
||||
|
||||
/// Parsed addresses do not always have *one* network. The problem is that legacy testnet,
|
||||
/// regtest and signet addresse use the same prefix instead of multiple different ones. When
|
||||
/// parsing, such addresses are always assumed to be testnet addresses (the same is true for
|
||||
|
|
Loading…
Reference in New Issue