diff --git a/program-libs/zero-copy/src/slice_mut.rs b/program-libs/zero-copy/src/slice_mut.rs index 1a5c5c3d8..c36bba58a 100644 --- a/program-libs/zero-copy/src/slice_mut.rs +++ b/program-libs/zero-copy/src/slice_mut.rs @@ -168,7 +168,7 @@ where } unsafe { - std::ptr::copy_nonoverlapping(slice.as_ptr(), self.data_as_mut_ptr(), slice.len()); + std::ptr::copy_nonoverlapping(slice.as_ptr(), self.data_as_mut_ptr(), len); } } } diff --git a/program-libs/zero-copy/src/vec.rs b/program-libs/zero-copy/src/vec.rs index 9f2040c60..3229e203b 100644 --- a/program-libs/zero-copy/src/vec.rs +++ b/program-libs/zero-copy/src/vec.rs @@ -199,7 +199,7 @@ where &mut self.data.as_mut_slice()[..len] } - pub fn copy_from_slice(&mut self, slice: &[T]) { + pub fn extend_from_slice(&mut self, slice: &[T]) { let len = self.len(); let new_len = len + slice.len(); if new_len > self.capacity() { diff --git a/program-libs/zero-copy/tests/vec_tests.rs b/program-libs/zero-copy/tests/vec_tests.rs index 617e49b44..c20f6a1cd 100644 --- a/program-libs/zero-copy/tests/vec_tests.rs +++ b/program-libs/zero-copy/tests/vec_tests.rs @@ -376,7 +376,7 @@ fn test_zero_copy_vec_to_array() { let capacity = 16; let mut data = vec![0; ZeroCopyVecUsize::::required_size_for_capacity(capacity)]; let mut vec = ZeroCopyVecUsize::::new(capacity, &mut data).unwrap(); - vec.copy_from_slice(&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); + vec.extend_from_slice(&[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); let arr: [u32; 16] = vec.try_into_array().unwrap(); assert_eq!(arr, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);