libcore: Implement equality for pointers

This commit is contained in:
Patrick Walton 2012-08-27 17:33:22 -07:00
parent 5792244d03
commit 9c04454e7b

View file

@ -18,6 +18,7 @@ export buf_len;
export position;
export Ptr;
import cmp::Eq;
import libc::{c_void, size_t};
#[nolink]
@ -170,6 +171,11 @@ impl<T> *T: Ptr {
pure fn is_not_null() -> bool { is_not_null(self) }
}
// Equality for pointers
impl<T: Eq> *T : Eq {
pure fn eq(&&other: *T) -> bool { self == other }
}
#[test]
fn test() {
unsafe {