Function abi_stable::pointer_trait::immutable_ref::to_nonnull

source ·
pub const fn to_nonnull<T>(from: T) -> NonNull<T::PtrTarget>
where T: GetPointerKind<Kind = PK_Reference>,
Expand description

Converts the from pointer to a NonNull.

§Example

use abi_stable::pointer_trait::immutable_ref;

use std::ptr::NonNull;

const X: NonNull<i8> = immutable_ref::to_nonnull(&3i8);
unsafe {
    assert_eq!(*X.as_ref(), 3i8);
}