Skip to main content

as_bytes

Function as_bytes 

Source
pub fn as_bytes<T: Pod>(data: &[T]) -> &[u8] ⓘ
Expand description

Reinterpret a slice of a bytemuck::Pod type as raw bytes without copying or converting endianness.

Unlike to_bytes, this does not convert byte order: the returned bytes are in the host’s native byte order, which only matches to_bytes’s little-endian output on a little-endian host.

§Examples

use mzdata_bindata::as_bytes;

let values: [i32; 2] = [7, -1];
let bytes = as_bytes(&values);
assert_eq!(bytes.len(), 8);