rust/src/test/run-pass/borrowed-ptr-pattern-option.rs
2012-09-23 13:30:20 -05:00

13 lines
274 B
Rust

fn select(x: &r/Option<int>, y: &r/Option<int>) -> &r/Option<int> {
match (x, y) {
(&None, &None) => x,
(&Some(_), _) => x,
(&None, &Some(_)) => y
}
}
fn main() {
let x = None;
let y = Some(3);
assert select(&x, &y).get() == 3;
}