Unsafe pointer utility functions

Implementation extensions for *T

Extension methods for pointers

Method is_null

pure fn is_null() -> bool

Returns true if the pointer is equal to the null pointer.

Method is_not_null

pure fn is_not_null() -> bool

Returns true if the pointer is not equal to the null pointer.

Function addr_of

pure fn addr_of<T>(val: T) -> *T

Get an unsafe pointer to a value

Function buf_len

unsafe fn buf_len<T>(buf: **T) -> uint

Return the offset of the first null pointer in buf.

Function const_offset

fn const_offset<T>(ptr: *const T, count: uint) -> *const T

Calculate the offset from a const pointer

Function is_not_null

pure fn is_not_null<T>(ptr: *const T) -> bool

Returns true if the pointer is not equal to the null pointer.

Function is_null

pure fn is_null<T>(ptr: *const T) -> bool

Returns true if the pointer is equal to the null pointer.

Function memcpy

unsafe fn memcpy<T>(dst: *T, src: *T, count: uint)

Copies data from one location to another

Copies count elements (not bytes) from src to dst. The source and destination may not overlap.

Function memmove

unsafe fn memmove<T>(dst: *T, src: *T, count: uint)

Copies data from one location to another

Copies count elements (not bytes) from src to dst. The source and destination may overlap.

Function memset

unsafe fn memset<T>(dst: *mut T, c: int, count: uint)

Function mut_addr_of

pure fn mut_addr_of<T>(val: T) -> *mut T

Get an unsafe mut pointer to a value

Function mut_offset

fn mut_offset<T>(ptr: *mut T, count: uint) -> *mut T

Calculate the offset from a mut pointer

Function null

pure fn null<T>() -> *T

Create an unsafe null pointer

Function offset

fn offset<T>(ptr: *T, count: uint) -> *T

Calculate the offset from a pointer

Function position

unsafe fn position<T>(buf: *T, f: fn(T) -> bool) -> uint

Return the first offset i such that f(buf[i]) == true.