Function aligned_ptr::ptr::replace[][src]

pub unsafe fn replace<T>(dst: *mut T, src: T) -> T
Expand description

The wrapper of core::ptr::replace which panics if the passed pointer is either null or not aligned.

Safety

The caller must follow the safety rules required by core::ptr::replace except the alignment and null rules.

Examples

use aligned_ptr::ptr;
use aligned_ptr::Error;

let mut x = 3;

let r = unsafe { ptr::replace(&mut x, 4) };
assert_eq!(x, 4);
assert_eq!(r, 3);