2011-08-12 06:37:25 -07:00
|
|
|
resource finish<T>(arg: {val: T, fin: fn(&T) }) { arg.fin(arg.val); }
|
2011-06-30 14:46:17 +02:00
|
|
|
|
|
|
|
fn main() {
|
2011-07-27 14:19:39 +02:00
|
|
|
let box = @mutable 10;
|
|
|
|
fn dec_box(i: &@mutable int) { *i -= 1; }
|
2011-06-30 14:46:17 +02:00
|
|
|
|
2011-07-27 14:19:39 +02:00
|
|
|
{ let i <- finish({val: box, fin: dec_box}); }
|
|
|
|
assert (*box == 9);
|
2011-08-12 06:37:25 -07:00
|
|
|
}
|