The code example used the wrong indices, this fixes it.
The code actually gets compiled to nothing because it has no side-effects, this uses an &mut reference instead.
Rust slices are defined to have a contiguous layout in memory and hence when you're able to observe it, the compiler guarantees the layout is as such (in this case because it's going through a reference, it'll always be laid out as described unless it's inlined).
I dug up a reference I read a few years back about specifically this topic, and added it (although I'm not sure if we're permitted to reference it).
This does four things:
&mut
reference instead.