Function aligned_ptr::ptr::write [−][src]
pub unsafe fn write<T>(p: *mut T, v: T)
Expand description
The wrapper of core::ptr::write
which panics if the passed pointer is either null or not
aligned.
Safety
The caller must follow the safety rules required by core::ptr::write
except the alignment
and null rules.
Panics
This function panics if p
is either null or not aligned correctly.
Examples
use aligned_ptr::ptr; use aligned_ptr::Error; let mut x = 3; let p = &mut x as *mut i32; unsafe { ptr::write(p, 4) }; assert_eq!(x, 4);