blob: e9e4c079eb0c74951897da124608dd0db53e682b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
// expect: 15i'm free as a bird! 15/body y7 x g
// destructors 2: drop(v, f) and v.drop(f) return v, v.drop = f; is a statement; this is the value. the spec example drops its temporary at the end of the statement
include rt;
fn main() {
rt.put_n(*heap(15).drop(fn() { rt.put_s("i'm free as a bird! "); rt.put_n(*this); }));
rt.put_c(10);
let g = drop(heap(1), fn() { rt.put_s("g "); });
let x = rt.new(int).drop(fn() { rt.put_s("x "); });
let y = rt.new(int); y.drop = fn() { rt.put_s("y"); rt.put_n(*this); rt.put_s(" "); };
*y = 7;
rt.put_s("body ");
return 0;
}
// zc0: skip
|