PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

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

http://github.com/jruderman/rust
Rust | 15 lines | 13 code | 2 blank | 0 comment | 1 complexity | 958742abe41d6ffd31e13f4c2c799c09 MD5 | raw file
 1class finish<T: copy> {
 2  let arg: {val: T, fin: extern fn(T)};
 3  new(arg: {val: T, fin: extern fn(T)}) {
 4    self.arg = arg;
 5  }
 6  drop { self.arg.fin(self.arg.val); }
 7}
 8
 9fn main() {
10    let box = @mut 10;
11    fn dec_box(&&i: @mut int) { *i -= 1; }
12
13    { let _i <- finish({val: box, fin: dec_box}); }
14    assert (*box == 9);
15}