rust/src/test/run-pass/resource-in-struct.rs
2012-03-26 18:35:18 -07:00

18 lines
326 B
Rust

// Ensures that putting resources inside structual types keeps
// working.
type closable = @mut bool;
resource close_res(i: closable) { *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);
}