pub fn group_vector_elements<T, const N: usize>(source: Vec<T>) -> Vec<[T; N]> 
Expand description

Transmutes a vector of n elements into a vector of n / N elements, each of which is an array of N elements.

This function just re-interprets the underlying memory and is thus zero-copy.

Panics

Panics if n is not divisible by N.

Example

let a = vec![0_u32, 1, 2, 3, 4, 5, 6, 7];
let b: Vec<[u32; 2]> = group_vector_elements(a);

assert_eq!(vec![[0, 1], [2, 3], [4, 5], [6, 7]], b);