summary refs log tree commit diff
path: root/src/test/run-pass/cap-clause-move.rs
blob: 0561af6ca6d3362765b483cddb5836f02926b53b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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;
}