2024-05-20 13:38:45 -05:00
|
|
|
//@ compile-flags: -O
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
// CHECK-LABEL: @write_u8_variant_a
|
2024-06-09 08:25:12 -05:00
|
|
|
// CHECK-NEXT: {{.*}}:
|
2024-05-20 13:38:45 -05:00
|
|
|
// CHECK-NEXT: icmp ugt
|
2024-06-17 02:36:21 -05:00
|
|
|
// CHECK-NEXT: getelementptr
|
|
|
|
// CHECK-NEXT: select i1 {{.+}} null
|
|
|
|
// CHECK-NEXT: insertvalue
|
|
|
|
// CHECK-NEXT: insertvalue
|
|
|
|
// CHECK-NEXT: ret
|
2024-05-20 13:38:45 -05:00
|
|
|
#[no_mangle]
|
2024-06-09 08:25:12 -05:00
|
|
|
pub fn write_u8_variant_a(bytes: &mut [u8], buf: u8, offset: usize) -> Option<&mut [u8]> {
|
2024-05-20 13:38:45 -05:00
|
|
|
let buf = buf.to_le_bytes();
|
2024-06-09 08:25:12 -05:00
|
|
|
bytes.get_mut(offset..).and_then(|bytes| bytes.get_mut(..buf.len()))
|
2024-05-20 13:38:45 -05:00
|
|
|
}
|