[][src]Function array_tools::split

pub fn split<T, A: FixedSizeArray<T>, LEFT: FixedSizeArray<T>, RIGHT: FixedSizeArray<T>>(
    array: A
) -> (LEFT, RIGHT)

A function to split arrays.

It is akin to slice's split_at, except it does not take split index as argument and infers it from output arrays' lengths.

use array_tools;

let array = [1u64, 2, 3, 4, 5, 6, 7, 8];
let (left, right): ([u64; 2], [u64; 6]) = array_tools::split(array);
assert_eq!(left, [1u64, 2]);
assert_eq!(right, [3u64, 4, 5, 6, 7, 8]);

Panics

Panics if sum of outputs' lengths is not equal to length of input.

Note

Currently it panics if output arrays have incompatible lengths, in future this behavior most certainly will be changed to perform this check at compile time.