mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 21:16:44 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			14 lines
		
	
	
		
			337 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			14 lines
		
	
	
		
			337 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| // ignore-debug: the debug assertions get in the way
 | |
| // compile-flags: -O
 | |
| #![crate_type = "lib"]
 | |
| 
 | |
| // CHECK-LABEL: @slice_fold_to_last
 | |
| #[no_mangle]
 | |
| pub fn slice_fold_to_last(slice: &[i32]) -> Option<&i32> {
 | |
|     // CHECK-NOT: loop
 | |
|     // CHECK-NOT: br
 | |
|     // CHECK-NOT: call
 | |
|     // CHECK: ret
 | |
|     slice.iter().fold(None, |_, i| Some(i))
 | |
| }
 | 
