rust/src/test/run-pass/regions-copy-closure.rs

16 lines
240 B
Rust
Raw Normal View History

struct closure_box {
cl: &fn(),
}
2012-09-19 00:45:24 -05:00
fn box_it(+x: &r/fn()) -> closure_box/&r {
closure_box {cl: move x}
}
fn main() {
let mut i = 3;
let cl_box = box_it(|| i += 1);
assert i == 3;
2012-12-01 17:25:17 -06:00
(cl_box.cl)();
assert i == 4;
}