PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/jruderman/rust
Rust | 13 lines | 12 code | 1 blank | 0 comment | 2 complexity | 05dd822b8b8025030643887017292a51 MD5 | raw file
 1class shrinky_pointer {
 2  let i: @@mut int;
 3  fn look_at() -> int { return **(self.i); }
 4  new(i: @@mut int) { self.i = i; }
 5  drop { log(error, ~"Hello!"); **(self.i) -= 1; }
 6}
 7
 8fn main() {
 9    let my_total = @@mut 10;
10    { let pt <- shrinky_pointer(my_total); assert (pt.look_at() == 10); }
11    log(error, fmt!{"my_total = %d", **my_total});
12    assert (**my_total == 9);
13}