diff options
| author | mendess <pedro.mendes.26@gmail.com> | 2020-05-23 14:08:53 +0100 |
|---|---|---|
| committer | mendess <pedro.mendes.26@gmail.com> | 2020-05-23 14:08:53 +0100 |
| commit | a5734ca41748dfd62904c1b5a1ade7ecd0f9c11e (patch) | |
| tree | f427286a127d373041a2908595f98548fe844de5 /src/liballoc | |
| parent | 75b0a68f35a06fc7aed8aa95831df8eace4afffb (diff) | |
| download | rust-a5734ca41748dfd62904c1b5a1ade7ecd0f9c11e.tar.gz rust-a5734ca41748dfd62904c1b5a1ade7ecd0f9c11e.zip | |
Override Box::<[T]>::clone_from
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/boxed.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 8ef6090c743..bbe68e4222a 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -1090,6 +1090,14 @@ impl<T: Clone> Clone for Box<[T]> { fn clone(&self) -> Self { self.to_vec().into_boxed_slice() } + + fn clone_from(&mut self, other: &Self) { + if self.len() == other.len() { + self.clone_from_slice(&other); + } else { + *self = other.clone(); + } + } } #[stable(feature = "box_borrow", since = "1.1.0")] |
