MCPcopy Index your code
hub / github.com/encounter/objdiff / read_u16

Function read_u16

objdiff-core/src/obj/mdebug.rs:379–387  ·  view source on GitHub ↗
(data: &[u8], cursor: &mut usize, endianness: Endianness)

Source from the content-addressed store, hash-verified

377}
378
379fn read_u16(data: &[u8], cursor: &mut usize, endianness: Endianness) -> Result<u16> {
380 ensure!(*cursor + 2 <= data.len(), "unexpected EOF while reading u16");
381 let bytes: [u8; 2] = data[*cursor..*cursor + 2].try_into().unwrap();
382 *cursor += 2;
383 Ok(match endianness {
384 Endianness::Big => u16::from_be_bytes(bytes),
385 Endianness::Little => u16::from_le_bytes(bytes),
386 })
387}
388
389fn read_u32(data: &[u8], cursor: &mut usize, endianness: Endianness) -> Result<u32> {
390 ensure!(*cursor + 4 <= data.len(), "unexpected EOF while reading u32");

Callers 2

parse_line_info_dwarf1Function · 0.70
parseMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected