string: Use the iterator size_hint() in .extend()

This commit is contained in:
bluss 2014-12-07 21:31:24 +01:00
parent 6f4c11be3b
commit d7d5ccf9bb

@ -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)
}