rust/src/test/run-pass/cap-clause-move.rs
Tim Chevalier b18320446e Move over to calling ptr::addr_of
Everything should now call ptr::addr_of instead of
ptr::p2::addr_of. Only the pipes macro code when compiled
by stage0 will call ptr::p2::addr_of. Needs a snapshot to get
rid of that.
2012-10-01 15:12:09 -07:00

30 lines
1.0 KiB
Rust

fn main() {
let x = ~1;
let y = ptr::addr_of(&(*x)) as uint;
let lam_copy = fn@(copy x) -> uint { ptr::addr_of(&(*x)) as uint };
let lam_move = fn@(move x) -> uint { ptr::addr_of(&(*x)) as uint };
assert lam_copy() != y;
assert lam_move() == y;
let x = ~2;
let y = ptr::addr_of(&(*x)) as uint;
let lam_copy: fn@() -> uint = |copy x| ptr::addr_of(&(*x)) as uint;
let lam_move: fn@() -> uint = |move x| ptr::addr_of(&(*x)) as uint;
assert lam_copy() != y;
assert lam_move() == y;
let x = ~3;
let y = ptr::addr_of(&(*x)) as uint;
let snd_copy = fn~(copy x) -> uint { ptr::addr_of(&(*x)) as uint };
let snd_move = fn~(move x) -> uint { ptr::addr_of(&(*x)) as uint };
assert snd_copy() != y;
assert snd_move() == y;
let x = ~4;
let y = ptr::addr_of(&(*x)) as uint;
let lam_copy: fn~() -> uint = |copy x| ptr::addr_of(&(*x)) as uint;
let lam_move: fn~() -> uint = |move x| ptr::addr_of(&(*x)) as uint;
assert lam_copy() != y;
assert lam_move() == y;
}