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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
312 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 12:39:39 +00:00
match (x, y) {
(&None, &None) => x,
(&Some(_), _) => x,
(&None, &Some(_)) => y
}
}
pub fn main() {
2012-09-23 12:39:39 +00:00
let x = None;
let y = Some(3);
assert_eq!(select(&x, &y).unwrap(), 3);
}