I want to copy the values at one slice of an array into another slice.
The obvious way (using iteration) is:
for i in 0..10 {
self.ram[i] = self.ram[20 + i];
}
However, that seems rather inefficient.
The usual way to copy a slice:
arr[0..10].copy_from_slice(&arr[20..30]);
does not work as arr is borrowed twice.
The only other way to do this that comes to mind is std::ptr::copy_nonoverlapping, which is unsafe.
What is the best way to copy a slice into its own array (while knowing that source and destination do not overlap)?