Skip to content

Commit a5734ca

Browse files
committed
Override Box::<[T]>::clone_from
1 parent 75b0a68 commit a5734ca

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/liballoc/boxed.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,14 @@ impl<T: Clone> Clone for Box<[T]> {
10901090
fn clone(&self) -> Self {
10911091
self.to_vec().into_boxed_slice()
10921092
}
1093+
1094+
fn clone_from(&mut self, other: &Self) {
1095+
if self.len() == other.len() {
1096+
self.clone_from_slice(&other);
1097+
} else {
1098+
*self = other.clone();
1099+
}
1100+
}
10931101
}
10941102

10951103
#[stable(feature = "box_borrow", since = "1.1.0")]

0 commit comments

Comments
 (0)