string: Use the iterator size_hint() in .extend()
This commit is contained in:
parent
6f4c11be3b
commit
d7d5ccf9bb
1 changed files with 2 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue