How to copy a slice optimally?

How to copy content from one slice to another properly and optimally?

fn copy<'a, 'b, T>(src: &'a [T], dst: &'b [T]) {
    assert!(src.len() == dst.len());
    *dst = *src;

It is implied that both slices always have the same length.


Are you sure you can do better then <[T]>::copy_from_slice?


That is what I had been looking for. Thank you!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.