winter_utils

Function transpose_slice

source
pub fn transpose_slice<T: Copy + Send + Sync, const N: usize>(
    source: &[T],
) -> Vec<[T; N]>
Expand description

Transposes a slice of n elements into a matrix with N columns and n/N rows.

When concurrent feature is enabled, the slice will be transposed using multiple threads.

§Panics

Panics if n is not divisible by N.

§Example

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

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