summaryrefslogtreecommitdiffstats
path: root/src/test/ui/binding/borrowed-ptr-pattern-option.rs
blob: 319b8631e8dde5bb39e860014089fb41103b8af7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// run-pass

fn select<'r>(x: &'r Option<isize>, y: &'r Option<isize>) -> &'r Option<isize> {
    match (x, y) {
        (&None, &None) => x,
        (&Some(_), _) => x,
        (&None, &Some(_)) => y
    }
}

pub fn main() {
    let x = None;
    let y = Some(3);
    assert_eq!(select(&x, &y).unwrap(), 3);
}