Use assert_eq! in copy_from_slice

This will print both lengths when the assertion fails instead of just saying that they're different.
This commit is contained in:
Jonas Schievink 2018-06-24 20:11:56 +02:00 committed by GitHub
parent 01cc982e93
commit 6b0c2fd1d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1642,8 +1642,8 @@ impl<T> [T] {
/// [`split_at_mut`]: #method.split_at_mut
#[stable(feature = "copy_from_slice", since = "1.9.0")]
pub fn copy_from_slice(&mut self, src: &[T]) where T: Copy {
assert!(self.len() == src.len(),
"destination and source slices have different lengths");
assert_eq!(self.len(), src.len(),
"destination and source slices have different lengths");
unsafe {
ptr::copy_nonoverlapping(
src.as_ptr(), self.as_mut_ptr(), self.len());