Function aligned_ptr::ptr::as_ref [−][src]
pub unsafe fn as_ref<'a, T>(p: *const T) -> &'a T
Expand description
The wrapper of &*p
which panics if p
is either null or not aligned.
Safety
The caller must follow the safety rules listed at core::ptr
except the alignment and null
rules.
Panics
This function panics if p
is either null or not aligned correctly.
Examples
use aligned_ptr::ptr; let x = 3; let p = &x as *const i32; let r = unsafe { ptr::as_ref(p) }; assert_eq!(*r, 3);