rust/src/test/run-pass/resource-destruct.rs

17 lines
287 B
Rust
Raw Normal View History

resource shrinky_pointer(@mutable int i) {
2011-06-28 10:47:56 -05:00
*i -= 1;
}
fn look_at(&shrinky_pointer pt) -> int {
ret **pt;
}
fn main() {
auto my_total = @mutable 10;
{
auto pt <- shrinky_pointer(my_total);
assert (look_at(pt) == 10);
}
assert (*my_total == 9);
}