rust/tests/ui/binding/borrowed-ptr-pattern-option.rs

16 lines
311 B
Rust
Raw Normal View History

// run-pass
fn select<'r>(x: &'r Option<isize>, y: &'r Option<isize>) -> &'r Option<isize> {
2012-09-23 07:39:39 -05:00
match (x, y) {
(&None, &None) => x,
(&Some(_), _) => x,
(&None, &Some(_)) => y
}
}
pub fn main() {
2012-09-23 07:39:39 -05:00
let x = None;
let y = Some(3);
assert_eq!(select(&x, &y).unwrap(), 3);
}