Skip to content

Commit 48267a8

Browse files
author
bluss
committed
---
yaml --- r: 163166 b: refs/heads/snap-stage3 c: 5ba7c5d h: refs/heads/master v: v3
1 parent 3b986ba commit 48267a8

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 9146a919b616e39e528e4d7100d16eef52f1f852
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: d7d5ccf9bb3bc63f347d8d5441092f20a3fe7088
4+
refs/heads/snap-stage3: 5ba7c5da62bae732bf466191dbeb5f699ba44d70
55
refs/heads/try: 20cbbffeefc1f35e2ea63afce7b42fbd79611d42
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libcollections/string.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,15 @@ impl FromIterator<char> for String {
729729
}
730730
}
731731

732+
#[experimental = "waiting on FromIterator stabilization"]
733+
impl<'a> FromIterator<&'a str> for String {
734+
fn from_iter<I:Iterator<&'a str>>(iterator: I) -> String {
735+
let mut buf = String::new();
736+
buf.extend(iterator);
737+
buf
738+
}
739+
}
740+
732741
#[experimental = "waiting on Extend stabilization"]
733742
impl Extend<char> for String {
734743
fn extend<I:Iterator<char>>(&mut self, mut iterator: I) {
@@ -740,6 +749,18 @@ impl Extend<char> for String {
740749
}
741750
}
742751

752+
#[experimental = "waiting on Extend stabilization"]
753+
impl<'a> Extend<&'a str> for String {
754+
fn extend<I: Iterator<&'a str>>(&mut self, mut iterator: I) {
755+
// A guess that at least one byte per iterator element will be needed.
756+
let (lower_bound, _) = iterator.size_hint();
757+
self.reserve(lower_bound);
758+
for s in iterator {
759+
self.push_str(s)
760+
}
761+
}
762+
}
763+
743764
impl PartialEq for String {
744765
#[inline]
745766
fn eq(&self, other: &String) -> bool { PartialEq::eq(&**self, &**other) }

0 commit comments

Comments
 (0)