about summary refs log tree commit diff
path: root/tests/codegen/issues/issue-112509-slice-get-andthen-get.rs
blob: fc04a6cc41abb5752ca082897755e3bd624b0495 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//@ compile-flags: -O
//@ min-llvm-version: 17
#![crate_type = "lib"]

// CHECK-LABEL: @write_u8_variant_a
// CHECK: getelementptr
// CHECK-NEXT: icmp ugt
#[no_mangle]
pub fn write_u8_variant_a(
    bytes: &mut [u8],
    buf: u8,
    offset: usize,
) -> Option<&mut [u8]> {
    let buf = buf.to_le_bytes();
    bytes
        .get_mut(offset..).and_then(|bytes| bytes.get_mut(..buf.len()))
}