Add ptr::ref_eq()
This commit is contained in:
@@ -13,9 +13,9 @@ export memcpy;
|
|||||||
export memmove;
|
export memmove;
|
||||||
export memset;
|
export memset;
|
||||||
export to_uint;
|
export to_uint;
|
||||||
|
export ref_eq;
|
||||||
export buf_len;
|
export buf_len;
|
||||||
export position;
|
export position;
|
||||||
export extensions;
|
|
||||||
export ptr;
|
export ptr;
|
||||||
|
|
||||||
import libc::{c_void, size_t};
|
import libc::{c_void, size_t};
|
||||||
@@ -150,6 +150,12 @@ fn to_uint<T>(thing: &T) -> uint unsafe {
|
|||||||
unsafe::reinterpret_cast(thing)
|
unsafe::reinterpret_cast(thing)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Determine if two borrowed pointers point to the same thing.
|
||||||
|
#[inline(always)]
|
||||||
|
fn ref_eq<T>(thing: &T, other: &T) -> bool {
|
||||||
|
to_uint(thing) == to_uint(other)
|
||||||
|
}
|
||||||
|
|
||||||
trait ptr {
|
trait ptr {
|
||||||
pure fn is_null() -> bool;
|
pure fn is_null() -> bool;
|
||||||
pure fn is_not_null() -> bool;
|
pure fn is_not_null() -> bool;
|
||||||
|
|||||||
Reference in New Issue
Block a user