2012-07-04 16:53:12 -05:00
|
|
|
//! Operations on shared box types
|
2012-03-06 21:09:32 -06:00
|
|
|
|
2012-08-13 19:11:33 -05:00
|
|
|
// NB: transitionary, de-mode-ing.
|
|
|
|
#[forbid(deprecated_mode)];
|
|
|
|
#[forbid(deprecated_pattern)];
|
|
|
|
|
2011-12-13 18:25:51 -06:00
|
|
|
export ptr_eq;
|
|
|
|
|
2012-06-24 22:18:18 -05:00
|
|
|
pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
|
2012-07-04 16:53:12 -05:00
|
|
|
//! Determine if two shared boxes point to the same object
|
2012-06-24 22:18:18 -05:00
|
|
|
unsafe { ptr::addr_of(*a) == ptr::addr_of(*b) }
|
2011-12-13 18:25:51 -06:00
|
|
|
}
|
2012-01-17 19:28:21 -06:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test() {
|
|
|
|
let x = @3;
|
|
|
|
let y = @3;
|
|
|
|
assert (ptr_eq::<int>(x, x));
|
|
|
|
assert (ptr_eq::<int>(y, y));
|
|
|
|
assert (!ptr_eq::<int>(x, y));
|
|
|
|
assert (!ptr_eq::<int>(y, x));
|
|
|
|
}
|