[][src]Function array_tools::split

pub fn split<T, A, L, R>(array: A) -> (L, R) where
    A: FixedSizeArray<T>,
    L: FixedSizeArray<T>,
    R: FixedSizeArray<T>, 

Splits array into two subarrays.

Because this function deals with arrays of constant size, it does not expect any arguments, instead it expects two generic parameters - a two array types that represent output subarrays. These must have the same element type that input array does, sum of their lengths must match exactly that of input array.

Does not perform any cloning operations, only moves values.


Panics if sum of output subarrays' length does not match exactly the length of input array.


Though currently it panics if output arrays have incompatible lengths, this behavior will be changed to perform this check at compile time, when this will become possible.


use array_tools::split;

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]);