diff options
| author | bluss <bluss> | 2014-12-07 21:31:24 +0100 |
|---|---|---|
| committer | bluss <bluss> | 2014-12-07 21:31:24 +0100 |
| commit | d7d5ccf9bb3bc63f347d8d5441092f20a3fe7088 (patch) | |
| tree | 2e876b7ace090115ef2396c81b3aaa8b71430d0e /src/libcollections/string.rs | |
| parent | 6f4c11be3b9706d1ba0e1b74b89de1478410a56f (diff) | |
| download | rust-d7d5ccf9bb3bc63f347d8d5441092f20a3fe7088.tar.gz rust-d7d5ccf9bb3bc63f347d8d5441092f20a3fe7088.zip | |
string: Use the iterator size_hint() in .extend()
Diffstat (limited to 'src/libcollections/string.rs')
| -rw-r--r-- | src/libcollections/string.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index fbb0bb5c4ce..961fca0f02b 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -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) } |
