rust/tests/codegen/slice-iter-fold.rs
2024-02-23 18:04:01 -05:00

13 lines
285 B
Rust

//@ 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))
}