pub const unsafe fn from_nonnull<T>(from: NonNull<T::PtrTarget>) -> Twhere
T: GetPointerKind<Kind = PK_Reference>,Expand description
Constructs this pointer from a NonNull.
§Safety
from must be a non-dangling pointer from a call to to_nonnull or
to_raw_ptr on an instance of T or a compatible pointer type.
§Example
use abi_stable::pointer_trait::immutable_ref;
const X: &u32 = unsafe {
let nn = abi_stable::utils::ref_as_nonnull(&5u32);
immutable_ref::from_nonnull(nn)
};
assert_eq!(*X, 5u32);