Trait std::ptr::RawPtrExperimental
[-]
[+]
[src]
pub trait RawPtr<T> {
fn null() -> Self;
fn is_null(&self) -> bool;
fn to_uint(&self) -> uint;
unsafe fn as_ref(&self) -> Option<&'a T>;
unsafe fn offset(self, count: int) -> Self;
fn is_not_null(&self) -> bool { ... }
}Methods on 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 as_ref(&self) -> Option<&'a T>
Returns None if the pointer is null, or else returns a reference to the
value wrapped in Some.
Safety Notes
While this method and its mutable counterpart are 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.