rust/src/test/run-pass/resource-generic.rs
Brian Anderson 518dc52f85 Reformat
This changes the indexing syntax from .() to [], the vector syntax from ~[] to
[] and the extension syntax from #fmt() to #fmt[]
2011-08-20 11:04:00 -07:00

10 lines
233 B
Rust

resource finish<T>(arg: {val: T, fin: fn(&T)}) { arg.fin(arg.val); }
fn main() {
let box = @mutable 10;
fn dec_box(i: &@mutable int) { *i -= 1; }
{ let i <- finish({val: box, fin: dec_box}); }
assert (*box == 9);
}