We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cd1fa91 commit cea171bCopy full SHA for cea171b
src/libcore/slice.rs
@@ -1126,13 +1126,16 @@ pub trait MutableCloneableSlice<T> {
1126
}
1127
1128
#[unstable = "trait is unstable"]
1129
-impl<'a, T:Clone> MutableCloneableSlice<T> for &'a mut [T] {
+impl<'a, T: Clone> MutableCloneableSlice<T> for &'a mut [T] {
1130
#[inline]
1131
fn clone_from_slice(self, src: &[T]) -> uint {
1132
- for (a, b) in self.iter_mut().zip(src.iter()) {
1133
- a.clone_from(b);
+ let min = cmp::min(self.len(), src.len());
+ let dst = self.slice_to_mut(min);
1134
+ let src = src.slice_to(min);
1135
+ for i in range(0, min) {
1136
+ dst[i].clone_from(&src[i]);
1137
- cmp::min(self.len(), src.len())
1138
+ min
1139
1140
1141
0 commit comments