rust/src/test/run-pass/resource-destruct.rs
2011-07-27 15:54:33 +02:00

9 lines
258 B
Rust

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