[][src]Function safe_transmute::transmute_vec_pedantic

pub fn transmute_vec_pedantic<T: TriviallyTransmutable>(
    bytes: Vec<u8>
) -> Result<Vec<T>, Error>

Transform a byte vector into a vector of values.

The vector's allocated byte buffer will be reused when possible, and should not have extraneous data.

Errors

An error is returned in one of the following situations:

Examples

// Little-endian
assert_eq!(transmute_vec_pedantic::<u16>(vec![0x00, 0x01, 0x00, 0x02])?,
           vec![0x0100, 0x0200]);

assert!(transmute_vec_pedantic::<u32>(vec![0x04, 0x00, 0x00, 0x00, 0xED]).is_err());