Improve the docs on as_unchecked function
The `as_unchecked` method is never dangerous to call because an `Address<UncheckedNetwork>` provides a subset of functionality that is always ok to use. It is only dangerous to go the other way unchecked to checked.
This commit is contained in:
parent
8315760403
commit
769809f1f2
|
@ -353,8 +353,7 @@ impl<N: NetworkValidation> serde::Serialize for Address<N> {
|
||||||
/// Methods on [`Address`] that can be called on both `Address<NetworkChecked>` and
|
/// Methods on [`Address`] that can be called on both `Address<NetworkChecked>` and
|
||||||
/// `Address<NetworkUnchecked>`.
|
/// `Address<NetworkUnchecked>`.
|
||||||
impl<V: NetworkValidation> Address<V> {
|
impl<V: NetworkValidation> Address<V> {
|
||||||
/// Returns a reference to the unchecked address, which is dangerous to use if the address
|
/// Returns a reference to the address as if it was unchecked.
|
||||||
/// is invalid in the context of `NetworkUnchecked`.
|
|
||||||
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>) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue