string: Use the iterator size_hint() in .extend()
This commit is contained in:
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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user