core: Add ptr::is_null/is_not_null

This commit is contained in:
Brian Anderson 2012-04-03 21:56:16 -07:00
parent e325146eb4
commit 3b8097dacc

View file

@ -49,7 +49,13 @@ fn mut_offset<T>(ptr: *mut T, count: uint) -> *mut T {
#[doc = "Create an unsafe null pointer"]
#[inline(always)]
fn null<T>() -> *T unsafe { ret unsafe::reinterpret_cast(0u); }
pure fn null<T>() -> *T unsafe { ret unsafe::reinterpret_cast(0u); }
#[doc = "Returns true if the pointer is equal to the null pointer"]
pure fn is_null<T>(ptr: *const T) -> bool { ptr == null() }
#[doc = "Returns true if the pointer is not equal to the null pointer"]
pure fn is_not_null<T>(ptr: *const T) -> bool { !is_null(ptr) }
#[doc = "
Copies data from one location to another