Skip to content

Commit 9c04454

Browse files
committed
libcore: Implement equality for pointers
1 parent 5792244 commit 9c04454

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libcore/ptr.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export buf_len;
1818
export position;
1919
export Ptr;
2020

21+
import cmp::Eq;
2122
import libc::{c_void, size_t};
2223

2324
#[nolink]
@@ -170,6 +171,11 @@ impl<T> *T: Ptr {
170171
pure fn is_not_null() -> bool { is_not_null(self) }
171172
}
172173

174+
// Equality for pointers
175+
impl<T: Eq> *T : Eq {
176+
pure fn eq(&&other: *T) -> bool { self == other }
177+
}
178+
173179
#[test]
174180
fn test() {
175181
unsafe {

0 commit comments

Comments
 (0)