2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
fn select<'r>(x: &'r Option<isize>, y: &'r Option<isize>) -> &'r Option<isize> {
|
2012-09-23 05:39:39 -07:00
|
|
|
match (x, y) {
|
|
|
|
(&None, &None) => x,
|
|
|
|
(&Some(_), _) => x,
|
|
|
|
(&None, &Some(_)) => y
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2012-09-23 05:39:39 -07:00
|
|
|
let x = None;
|
|
|
|
let y = Some(3);
|
2013-08-04 01:59:24 +02:00
|
|
|
assert_eq!(select(&x, &y).unwrap(), 3);
|
2013-02-14 11:47:00 -08:00
|
|
|
}
|