[][src]Function safe_transmute::guarded_transmute_bool_vec_permissive

pub fn guarded_transmute_bool_vec_permissive(
    bytes: Vec<u8>
) -> Result<Vec<bool>, Error>

Trasform a byte vector into a vector of bool.

The vector's allocated byte buffer will be reused when possible, and have as many instances of a type as will fit, rounded down.

Examples

assert_eq!(guarded_transmute_bool_vec_permissive(vec![0x00, 0x01, 0x00, 0x01])?,
           vec![false, true, false, true]);
assert_eq!(guarded_transmute_bool_vec_permissive(vec![0x01, 0x00, 0x00, 0x00, 0x01])?,
           vec![true, false, false, false, true]);
assert_eq!(guarded_transmute_bool_vec_permissive(vec![]), Ok(vec![]));