I am looking for a function similar to slice::split_at_mut. Let's name it split_at with the signature
pub fn split_at<T>(v: Vec<T>, mid: usize) -> (Vec<T>, Vec<T>)
such that
let v = vec![1, 2, 3, 4];
let (first, second) = split_at(v, 2);
assert_eq!(first, vec![1, 2]);
assert_eq!(second, vec![3, 4]);
The function should allocate no memory and simply split a vector into two. You don't need to worry about capacity as the resultant vectors will not be modified.
The nightly-only method Vec::into_raw_parts seems promising, but I am on the stable release channel which doesn't allow such methods.