Closed
Description
See the following code for an example:
struct Goodbye { msg: ~str }
impl Goodbye: Drop {
fn finalize(&self) {
io::println(self.msg);
}
}
pure fn test() -> Goodbye {
let x = Goodbye { msg: ~"Good" };
let _y = Goodbye { msg: ~"Bad" };
return x;
}
fn main() {
io::println("Before");
let _z = test();
io::println("After");
}
Result:
Before
Bad
After
Good