Function safe_transmute::guarded_transmute_vec_permissive
[−]
[src]
pub unsafe fn guarded_transmute_vec_permissive<T>(bytes: Vec<u8>) -> Vec<T>
Trasform a byte vector into a vector of an arbitrary type.
The vector's allocated byte buffer will be reused when possible, and have as many instances of a type as will fit, rounded down. Extraneous data is ignored.
Examples
// Little-endian assert_eq!(guarded_transmute_vec_permissive::<u16>(vec![0x00, 0x01, 0x00, 0x02]), vec![0x0100, 0x0200]); assert_eq!(guarded_transmute_vec_permissive::<u32>(vec![0x04, 0x00, 0x00, 0x00, 0xED]), vec![0x00000004]); assert_eq!(guarded_transmute_vec_permissive::<u16>(vec![0xED]), vec![]);