pub fn split<const N: usize, const M: usize, T>(
a: [T; N],
) -> ([T; M], [T; { _ }])
Expand description
Splits the given array a
at the given point M
. Returns a tuple
containing two arrays where the first element is an array containing all
elements from a[..M]
and the second element is an array containing all
elements from a[M..]
. No elements are dropped, copied or cloned.
ยงExample
let arr = [1usize, 2, 3, 4, 5];
// Currently, the turbofish syntax is required. rustc still cannot infer
// them even if you fully annotate these variables' types.
let (left, right) = split::<5, 3, usize>(arr);
assert_eq!(left, [1, 2, 3]);
assert_eq!(right, [4, 5]);