Skip to content

Commit

Permalink
string: Use the iterator size_hint() in .extend()
Browse files Browse the repository at this point in the history
  • Loading branch information
bluss committed Dec 7, 2014
1 parent 6f4c11b commit d7d5ccf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/libcollections/string.rs
Expand Up @@ -732,6 +732,8 @@ impl FromIterator<char> for String {
#[experimental = "waiting on Extend stabilization"]
impl Extend<char> for String {
fn extend<I:Iterator<char>>(&mut self, mut iterator: I) {
let (lower_bound, _) = iterator.size_hint();
self.reserve(lower_bound);
for ch in iterator {
self.push(ch)
}
Expand Down

0 comments on commit d7d5ccf

Please sign in to comment.