Skip to content

Commit d7d5ccf

Browse files
author
bluss
committed
string: Use the iterator size_hint() in .extend()
1 parent 6f4c11b commit d7d5ccf

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/libcollections/string.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ impl FromIterator<char> for String {
732732
#[experimental = "waiting on Extend stabilization"]
733733
impl Extend<char> for String {
734734
fn extend<I:Iterator<char>>(&mut self, mut iterator: I) {
735+
let (lower_bound, _) = iterator.size_hint();
736+
self.reserve(lower_bound);
735737
for ch in iterator {
736738
self.push(ch)
737739
}

0 commit comments

Comments
 (0)