rust/src/test/run-pass/resource-in-struct.rs

18 lines
326 B
Rust
Raw Normal View History

// Ensures that putting resources inside structual types keeps
// working.
2012-03-26 20:35:18 -05:00
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() {
2012-03-26 20:35:18 -05:00
let c = @mut true;
sink(none);
sink(some(close_res(c)));
assert (!*c);
}