mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
17 lines
480 B
Rust
17 lines
480 B
Rust
//@ compile-flags: -O
|
|
#![crate_type = "lib"]
|
|
|
|
// CHECK-LABEL: @write_u8_variant_a
|
|
// CHECK-NEXT: {{.*}}:
|
|
// CHECK-NEXT: icmp ugt
|
|
// CHECK-NEXT: getelementptr
|
|
// CHECK-NEXT: select i1 {{.+}} null
|
|
// CHECK-NEXT: insertvalue
|
|
// CHECK-NEXT: insertvalue
|
|
// CHECK-NEXT: ret
|
|
#[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()))
|
|
}
|