pub fn guarded_transmute_to_bytes_pod_many<T: PodTransmutable>(
from: &[T]
) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
Expand description
Transmute a slice of arbitrary types into a slice of their bytes.
Examples
Some u16
s:
assert_eq!(guarded_transmute_to_bytes_pod_many(&[0x0123u16, 0x4567u16]),
&[0x23, 0x01, 0x67, 0x45]);
An arbitrary type:
#[repr(C)]
#[derive(Clone, Copy)]
struct Gene {
x1: u8,
x2: u8,
}
unsafe impl PodTransmutable for Gene {}
assert_eq!(guarded_transmute_to_bytes_pod_many(&[Gene {
x1: 0x42,
x2: 0x69,
},
Gene {
x1: 0x12,
x2: 0x48,
}]),
&[0x42, 0x69, 0x12, 0x48]);