- for (dst, (old, new)) in new_buf.chunks_exact_mut(new_stride).zip(
- self.data.chunks_exact(self.stride).zip(
- src.get_data().chunks(src.get_stride()))) {
- dst[..old_len].copy_from_slice(&old[self.start..self.end]);
- dst[old_len..][..new_len].copy_from_slice(&new[..new_len]);
+ if old_len > 0 {
+ for (dst, (old, new)) in new_buf.chunks_exact_mut(new_stride).zip(
+ self.data.chunks_exact(self.stride).zip(
+ src.get_data().chunks(src.get_stride()))) {
+ dst[..old_len].copy_from_slice(&old[self.start..self.end]);
+ dst[old_len..][..new_len].copy_from_slice(&new[..new_len]);
+ }
+ } else {
+ for (dst, new) in new_buf.chunks_exact_mut(new_stride).zip(
+ src.get_data().chunks(src.get_stride())) {
+ dst[..new_len].copy_from_slice(&new[..new_len]);
+ }