Override Box::<[T]>::clone_from

This commit is contained in:
mendess 2020-05-23 14:08:53 +01:00
parent 75b0a68f35
commit a5734ca417

View file

@ -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")]