Unsafe operations

Function bump_box_refcount

fn bump_box_refcount<T>(t: @T)

Force-increment the reference count on a shared box. If used carelessly, this can leak the box. Use this in conjunction with transmute and/or reinterpret_cast when such calls would otherwise scramble a box's reference count

Function copy_lifetime

fn copy_lifetime<S, T>(_ptr: &a/S, ptr: &T) -> &a/T

Transforms lifetime of the second pointer to match the first.

Function copy_lifetime_vec

fn copy_lifetime_vec<S, T>(_ptr: &a/[S], ptr: &T) -> &a/T

Transforms lifetime of the second pointer to match the first.

Function forget

fn forget<T>(thing: T)

Move a thing into the void

The forget function will take ownership of the provided value but neglect to run any required cleanup or memory-management operations on it. This can be used for various acts of magick, particularly when using reinterpret_cast on pointer types.

Function reinterpret_cast

fn reinterpret_cast<T, U>(src: &T) -> U

Casts the value at src to U. The two types must have the same length.

Function transmute

fn transmute<L, G>(thing: L) -> G

Transform a value of one type into a value of another type. Both types must have the same size and alignment.

Example

assert transmute("L") == ~[76u8, 0u8];

Function transmute_immut

fn transmute_immut<T>(ptr: &a/mut T) -> &a/T

Coerce a mutable reference to be immutable.

Function transmute_immut_unsafe

fn transmute_immut_unsafe<T>(ptr: *const T) -> *T

Coerce an immutable reference to be mutable.

Function transmute_mut

fn transmute_mut<T>(ptr: &a/T) -> &a/mut T

Coerce an immutable reference to be mutable.

Function transmute_mut_region

fn transmute_mut_region<T>(ptr: &a/mut T) -> &b/mut T

Coerce a borrowed mutable pointer to have an arbitrary associated region.

Function transmute_mut_unsafe

fn transmute_mut_unsafe<T>(ptr: *const T) -> *mut T

Coerce an immutable reference to be mutable.

Function transmute_region

fn transmute_region<T>(ptr: &a/T) -> &b/T

Coerce a borrowed pointer to have an arbitrary associated region.