Function aligned_ptr::ptr::as_mut[][src]

pub unsafe fn as_mut<'a, T>(p: *mut T) -> &'a mut T
Expand description

The wrapper of &mut *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 mut x = 3;
let p = &mut x as *mut i32;
let r = unsafe { ptr::as_mut(p) };
*r = 4;
assert_eq!(x, 4);