about summary refs log tree commit diff
path: root/src/libcore/slice
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2018-06-28 16:07:12 -0600
committerGitHub <noreply@github.com>2018-06-28 16:07:12 -0600
commit85804f66be86509d5c2e8ff047e2edd47332986b (patch)
treec147060937241eeb3d9179e47fec829c3dba87b1 /src/libcore/slice
parent57aceeecc06b887b885908ffc3df917a9fabaa4b (diff)
parent6b0c2fd1d6caf3317da930912b9dc85ed92747f7 (diff)
downloadrust-85804f66be86509d5c2e8ff047e2edd47332986b.tar.gz
rust-85804f66be86509d5c2e8ff047e2edd47332986b.zip
Rollup merge of #51765 - jonas-schievink:patch-1, r=KodrAus
Use assert_eq! in copy_from_slice

This will print both lengths when the assertion fails instead of just saying that they're different.

Output of current stable and nightly (modulo the exact line number):
```
thread 'main' panicked at 'destination and source slices have different lengths', libcore/slice/mod.rs:1645:9
```

Output after this PR:
```
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `123`,
 right: `456`: destination and source slices have different lengths', libcore/slice/mod.rs:1645:9
```

Note that I have not run the tests locally.
Diffstat (limited to 'src/libcore/slice')
-rw-r--r--src/libcore/slice/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs
index e74e527927d..0cbdbc4ad66 100644
--- a/src/libcore/slice/mod.rs
+++ b/src/libcore/slice/mod.rs
@@ -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());