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

10 lines
258 B
Rust
Raw Normal View History

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