Skip to content

Commit cbd7f6e

Browse files
committed
---
yaml --- r: 236543 b: refs/heads/tmp c: e980129 h: refs/heads/master i: 236541: c1f0989 236539: cd500bd 236535: c7ec7b4 236527: bd589e3 236511: d2d9eec 236479: 726999d 236415: 11b0f79 236287: 208fc30 236031: fc5c0b8 235519: a8b5df3 v: v3
1 parent cb9d7d9 commit cbd7f6e

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: c3ca1820828f3ed6620b45b0cc2cc404e322a8ce
28+
refs/heads/tmp: e9801294a1e24ec8812b8bb827a5d6df5f9078a9
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/libcollections/binary_heap.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,22 @@ use vec::{self, Vec};
167167
/// item's ordering relative to any other item, as determined by the `Ord`
168168
/// trait, changes while it is in the heap. This is normally only possible
169169
/// through `Cell`, `RefCell`, global state, I/O, or unsafe code.
170-
#[derive(Clone)]
171170
#[stable(feature = "rust1", since = "1.0.0")]
172171
pub struct BinaryHeap<T> {
173172
data: Vec<T>,
174173
}
175174

175+
#[stable(feature = "rust1", since = "1.0.0")]
176+
impl<T: Clone> Clone for BinaryHeap<T> {
177+
fn clone(&self) -> Self {
178+
BinaryHeap { data: self.data.clone() }
179+
}
180+
181+
fn clone_from(&mut self, source: &Self) {
182+
self.data.clone_from(&source.data);
183+
}
184+
}
185+
176186
#[stable(feature = "rust1", since = "1.0.0")]
177187
impl<T: Ord> Default for BinaryHeap<T> {
178188
#[inline]

branches/tmp/src/libcollections/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
#![feature(unsafe_no_drop_flag, filling_drop)]
6363
#![feature(decode_utf16)]
6464
#![feature(utf8_error)]
65-
#![cfg_attr(test, feature(rand, test))]
65+
#![cfg_attr(test, feature(clone_from_slice, rand, test))]
6666

6767
#![feature(no_std)]
6868
#![no_std]

branches/tmp/src/libcollections/string.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use vec::Vec;
3030
use boxed::Box;
3131

3232
/// A growable string stored as a UTF-8 encoded buffer.
33-
#[derive(Clone, PartialOrd, Eq, Ord)]
33+
#[derive(PartialOrd, Eq, Ord)]
3434
#[stable(feature = "rust1", since = "1.0.0")]
3535
pub struct String {
3636
vec: Vec<u8>,
@@ -765,6 +765,17 @@ impl fmt::Display for FromUtf16Error {
765765
}
766766
}
767767

768+
#[stable(feature = "rust1", since = "1.0.0")]
769+
impl Clone for String {
770+
fn clone(&self) -> Self {
771+
String { vec: self.vec.clone() }
772+
}
773+
774+
fn clone_from(&mut self, source: &Self) {
775+
self.vec.clone_from(&source.vec);
776+
}
777+
}
778+
768779
#[stable(feature = "rust1", since = "1.0.0")]
769780
impl FromIterator<char> for String {
770781
fn from_iter<I: IntoIterator<Item=char>>(iterable: I) -> String {

branches/tmp/src/libcollections/vec.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,19 +1007,15 @@ impl<T:Clone> Clone for Vec<T> {
10071007

10081008
fn clone_from(&mut self, other: &Vec<T>) {
10091009
// drop anything in self that will not be overwritten
1010-
if self.len() > other.len() {
1011-
self.truncate(other.len())
1012-
}
1010+
self.truncate(other.len());
1011+
let len = self.len();
10131012

10141013
// reuse the contained values' allocations/resources.
1015-
for (place, thing) in self.iter_mut().zip(other) {
1016-
place.clone_from(thing)
1017-
}
1014+
self.clone_from_slice(&other[..len]);
10181015

10191016
// self.len <= other.len due to the truncate above, so the
10201017
// slice here is always in-bounds.
1021-
let slice = &other[self.len()..];
1022-
self.push_all(slice);
1018+
self.push_all(&other[len..]);
10231019
}
10241020
}
10251021

0 commit comments

Comments
 (0)