Function abi_stable::pointer_trait::immutable_ref::from_raw_ptr
source · pub const unsafe fn from_raw_ptr<T>(from: *const T::PtrTarget) -> Option<T>where
T: GetPointerKind<Kind = PK_Reference>,
Expand description
Converts a raw pointer to an T
pointer.
§Safety
This has the same safety requirements as from_nonnull
,
with the exception that null pointers are allowed.
§Example
use abi_stable::pointer_trait::immutable_ref;
unsafe {
const X: Option<&u8> = unsafe {
immutable_ref::from_raw_ptr(&13u8 as *const u8)
};
assert_eq!(*X.unwrap(), 13u8);
}