pub unsafe fn hex_dump<T>(ofs: usize, ptr: *const T, ascii: bool)Expand description
Dumps the memory occupied by a value of type T to the console.
This function takes a raw pointer to the data. The size of the data to dump
is determined by core::mem::size_of::<T>(). This function handles
potentially unaligned pointers by first performing an unaligned read.
§Safety
The caller must ensure that ptr is valid for reads of size_of::<T>()
bytes for the duration of this function call. The pointer does not need
to be aligned.
§Arguments
ofs- The starting offset for the first byte.ptr- A raw pointer to the data to be dumped.ascii- A flag to enable or disable the ASCII character view.
§Usage
let my_data: u32 = 0x12345678;
// This function is unsafe and must be called within an unsafe block.
unsafe {
hex_dump(0, &my_data, true);
}