mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
19 lines
321 B
Rust
19 lines
321 B
Rust
//@ compile-flags: -O
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
#[no_mangle]
|
|
pub fn test() -> u32 {
|
|
// CHECK-LABEL: @test(
|
|
// CHECK: ret i32 13
|
|
let s = [1, 2, 3, 4, 5, 6, 7];
|
|
|
|
let mut iter = s.iter();
|
|
let mut sum = 0;
|
|
while let Some(_) = iter.next() {
|
|
sum += iter.next().map_or(1, |&x| x)
|
|
}
|
|
|
|
sum
|
|
}
|