summary refs log tree commit diff
path: root/src/test/run-pass/resource-in-struct.rs
blob: 8582bdeddfabb301673082a6fac6fcace10c2384 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Ensures that class dtors run if the object is inside an enum
// variant

type closable = @mut bool;

class close_res {
  let i: closable;
 
  new(i: closable) { self.i = i; }
  drop { *(self.i) = false; }
}

enum option<T> { none, some(T), }

fn sink(res: option<close_res>) { }

fn main() {
    let c = @mut true;
    sink(none);
    sink(some(close_res(c)));
    assert (!*c);
}