pub fn copy<T>(dst: &mut [T], src: &[T]) -> usizewhere
T: Copy,Expand description
Copies as many T as possible from src into dst, returning the number of T copied. This
function is short form for dst.copy_from_slice(src), but accounts for if their lengths are
unequal to avoid panics.
With the nightly feature, [u8] is specialized to use Read, which is implemented
specially for small slices.
ยงExamples
use slice_copy::copy;
let mut l = vec![1 as u8, 2, 3, 4, 5];
let r = vec![10, 11, 12];
let n = copy(&mut l, &r);
assert_eq!(n, 3);
assert_eq!(l, vec![10, 11, 12, 4, 5]);