mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 13:04:42 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			16 lines
		
	
	
		
			311 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			16 lines
		
	
	
		
			311 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| // 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);
 | |
| }
 | 
