[src]

Trait std::ptr::RawPtr

pub trait RawPtr<T> {
    fn null() -> Self;
    fn is_null(&self) -> bool;
    fn to_uint(&self) -> uint;
    unsafe fn to_option(&self) -> Option<&T>;
    unsafe fn offset(self, count: int) -> Self;

    fn is_not_null(&self) -> bool { ... }
}

Extension methods for raw pointers.

Required Methods

fn null() -> Self

Returns the null pointer.

fn is_null(&self) -> bool

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

fn to_uint(&self) -> uint

Returns the value of this pointer (ie, the address it points to)

unsafe fn to_option(&self) -> Option<&T>

Returns None if the pointer is null, or else returns the value wrapped in Some.

Safety Notes

While this method is useful for null-safety, it is important to note that this is still an unsafe operation because the returned value could be pointing to invalid memory.

unsafe fn offset(self, count: int) -> Self

Calculates the offset from a pointer. The offset must be in-bounds of the object, or one-byte-past-the-end. count is in units of T; e.g. a count of 3 represents a pointer offset of 3 * sizeof::<T>() bytes.

Provided Methods

fn is_not_null(&self) -> bool

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

Implementors