revm_bytecode/
utils.rs

1//! Various utilities for the bytecode
2
3/// Reads a big-endian `i16` from a `u8` pointer.
4///
5/// # Safety
6///
7/// The pointer must point to at least 2 bytes.
8#[inline]
9pub unsafe fn read_i16(ptr: *const u8) -> i16 {
10    read_u16(ptr) as i16
11}
12
13/// Reads a big-endian `u16` from a `u8` pointer.
14///
15/// # Safety
16///
17/// The pointer must point to at least 2 bytes.
18#[inline]
19pub unsafe fn read_u16(ptr: *const u8) -> u16 {
20    u16::from_be_bytes(unsafe { ptr.cast::<[u8; 2]>().read() })
21}