Function safe_transmute::guarded_transmute_pod_vec_pedantic
[−]
[src]
pub fn guarded_transmute_pod_vec_pedantic<T: PodTransmutable>(
bytes: Vec<u8>
) -> Result<Vec<T>, Error>
Trasform a byte vector into a vector of POD.
The vector's allocated byte buffer will be reused when possible, and should not have extraneous data.
Examples
// Little-endian assert_eq!(guarded_transmute_pod_vec_pedantic::<u16>(vec![0x00, 0x01, 0x00, 0x02]).unwrap(), vec![0x0100, 0x0200]); assert!(guarded_transmute_pod_vec_pedantic::<u32>(vec![0x04, 0x00, 0x00, 0x00, 0xED]) .is_err());