Unsafe pointer utility functions

Interface Ptr

Method is_null

fn is_null() -> bool

Method is_not_null

fn is_not_null() -> bool

Method offset

fn offset(count: uint) -> self

Implementation of Ptr<T> for *T

Extension methods for immutable pointers

Method is_null

fn is_null() -> bool

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

Method is_not_null

fn is_not_null() -> bool

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

Method offset

fn offset(count: uint) -> *T

Calculates the offset from a pointer.

Implementation of Ptr<T> for *mut T

Extension methods for mutable pointers

Method is_null

fn is_null() -> bool

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

Method is_not_null

fn is_not_null() -> bool

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

Method offset

fn offset(count: uint) -> *mut T

Calculates the offset from a mutable pointer.

Function addr_of

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

Get an unsafe pointer to a value

Function buf_len

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

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

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

Function is_null

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

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

Function memcpy

fn memcpy<T>(dst: *mut T, src: *const 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

fn memmove<T>(dst: *mut T, src: *const 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

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

Function mut_addr_of

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

Get an unsafe mut pointer to a value

Function mut_null

fn mut_null<T>() -> *mut T

Create an unsafe mutable null pointer

Function mut_offset

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

Calculate the offset from a mut pointer

Function null

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

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

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

Function ref_eq

fn ref_eq<T>(thing: &a/T, other: &b/T) -> bool

Determine if two borrowed pointers point to the same thing.

Function to_const_unsafe_ptr

fn to_const_unsafe_ptr<T>(thing: &const T) -> *const T

Transform a const region pointer - &const T - to a const unsafe pointer - *const T. This is safe, but is implemented with an unsafe block due to reinterpret_cast.

Function to_mut_unsafe_ptr

fn to_mut_unsafe_ptr<T>(thing: &mut T) -> *mut T

Transform a mutable region pointer - &mut T - to a mutable unsafe pointer - *mut T. This is safe, but is implemented with an unsafe block due to reinterpret_cast.

Function to_uint

fn to_uint<T>(thing: &T) -> uint

Cast a region pointer - &T - to a uint. This is safe, but is implemented with an unsafe block due to reinterpret_cast.

(I couldn't think of a cutesy name for this one.)

Function to_unsafe_ptr

fn to_unsafe_ptr<T>(thing: &T) -> *T

Transform a region pointer - &T - to an unsafe pointer - *T. This is safe, but is implemented with an unsafe block due to reinterpret_cast.