rust/src/test/run-pass/resource-destruct.rs
2012-03-26 18:35:18 -07:00

10 lines
250 B
Rust

resource shrinky_pointer(i: @mut int) { *i -= 1; }
fn look_at(pt: shrinky_pointer) -> int { ret **pt; }
fn main() {
let my_total = @mut 10;
{ let pt <- shrinky_pointer(my_total); assert (look_at(pt) == 10); }
assert (*my_total == 9);
}