ed357af980
And monomorphize dtors correctly.
16 lines
329 B
Rust
16 lines
329 B
Rust
class finish<T: copy> {
|
|
let arg: {val: T, fin: native fn(T)};
|
|
new(arg: {val: T, fin: native fn(T)}) {
|
|
self.arg = arg;
|
|
}
|
|
drop { self.arg.fin(self.arg.val); }
|
|
}
|
|
|
|
fn main() {
|
|
let box = @mut 10;
|
|
fn dec_box(&&i: @mut int) { *i -= 1; }
|
|
|
|
{ let _i <- finish({val: box, fin: dec_box}); }
|
|
assert (*box == 9);
|
|
}
|