Crate rawpointer[][src]

Rawpointer adds extra utility methods to raw pointers *const T, *mut T and NonNull<T>.

Features include:

use rawpointer::PointerExt;

unsafe {
    // In this example:
    // Use .post_inc() to iterate and overwrite the first four
    // elements of the array.

    let mut xs = [0; 16];
    let mut ptr = xs.as_mut_ptr();
    let end = ptr.offset(4);
    let mut i = 0;
    while ptr != end {
        *ptr.post_inc() = i;
        i += 1;
    }
    assert_eq!(&xs[..8], &[0, 1, 2, 3, 0, 0, 0, 0]);
}

Safety

See the Rust core::ptr documentation for more information.

Rust Version

This version of the crate requires Rust 1.26 or later

Traits

PointerExt

Extension methods for raw pointers

Functions

ptrdistance

Return the number of elements of T from start to end.
Return the arithmetic difference if T is zero size.