Function copy_in_place::copy_in_place [−][src]
pub fn copy_in_place<T: Copy>(
slice: &mut [T],
src: usize,
dest: usize,
count: usize
)
Copies elements from one part of a slice to another part of the same slice, using a memmove.
src
is the starting index of the source region. dest
is the starting
index of the destination region. count
is the number of elements in
both regions. The two regions may overlap.
The ends of the two regions, src + count
and dest + count
, must be
less than or equal to self.len()
.
Panics
This function will panic if either region exceeds the end of the slice.
Examples
Copying four bytes within a slice:
let mut bytes = *b"Hello, World!"; copy_in_place(&mut bytes, 1, 8, 4); assert_eq!(&bytes, b"Hello, Wello!");