Want to get multiple mutable slices from a vector?

Rust will complain about:

let range_a = &mut vec[0..10];
let range_b = &mut vec[10..];

Because any mutable loan is exclusive for the entire Vec. Rust doesn't understand that the ranges are non-overlapping. The solution is to use .split_at_mut():

let (range_a, range_b) = vec.split_at_mut(10);

If you want to completely split a Vec into sub-ranges, see vec.chunks_mut().

This is not an issue with immutable slices, because they are shared loans, and many of them can exist at the same time.

Try it: Rust Playground