Function winter_utils::transpose_slice[][src]

pub fn transpose_slice<T: Copy + Send + Sync, const N: usize>(
    source: &[T]
) -> Vec<[T; N]>
Notable traits for Vec<u8, A>
impl<A> Write for Vec<u8, A> where
    A: Allocator
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);