Don't worry, this actually isn't simple. But you can split it and then index the separate slices.
If you really just want 0 and 1, then you can use:
let (first, tail) = data.split_first_mut().unwrap();
do_something(first, &mut tail[0]);
If you want some arbitrary indexes i
and j
, assuming i < j
:
let (head, tail) = data.split_at_mut(i + 1);
do_something(&mut head[i], &mut tail[j - i - 1]);