pub fn pod_collect_to_vec<A: NoUninit, B: NoUninit + AnyBitPattern>(
    src: &[A]
) -> Vec<B>
Expand description

This “collects” a slice of pod data into a vec of a different pod type.

Unlike with cast_slice and cast_slice_mut, this will always work.

The output vec will be of a minimal size/capacity to hold the slice given.

let halfwords: [u16; 4] = [5, 6, 7, 8];
let vec_of_words: Vec<u32> = pod_collect_to_vec(&halfwords);
if cfg!(target_endian = "little") {
  assert_eq!(&vec_of_words[..], &[0x0006_0005, 0x0008_0007][..])
} else {
  assert_eq!(&vec_of_words[..], &[0x0005_0006, 0x0007_0008][..])
}