os-rust/tests/codegen/issues/issue-109328-split_first.rs
Lzu Tao f9edd864df Apply suggestions from code review
Co-authored-by: Nikita Popov <github@npopov.com>
2024-06-09 13:25:12 +00:00

16 lines
346 B
Rust

//@ compile-flags: -O
#![crate_type = "lib"]
// CHECK-LABEL: @foo
// CHECK-NEXT: {{.*}}:
// CHECK-NEXT: getelementptr inbounds
// CHECK-NEXT: load i64
// CHECK-NEXT: icmp eq i64
// CHECK-NEXT: br i1
#[no_mangle]
pub fn foo(input: &mut &[u64]) -> Option<u64> {
let (first, rest) = input.split_first()?;
*input = rest;
Some(*first)
}