diff options
| author | bors <bors@rust-lang.org> | 2018-03-31 06:40:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-03-31 06:40:56 +0000 |
| commit | 085c4b43b567298aa7af21a92426f49633919047 (patch) | |
| tree | af7281d967b5867d7b4536bebff79c2041625a20 /src/libsyntax_ext | |
| parent | 3c5f8509581c1a3072496db04a6af32c76d1af61 (diff) | |
| parent | 5057e3c9e10f329d39a0e45607cf6a9ab467f7bf (diff) | |
Auto merge of #49201 - Phlosioneer:add-trivial-size-hints, r=SimonSapin
Implement some trivial size_hints for various iterators This also implements ExactSizeIterator where applicable. Addresses most of the Iterator traits mentioned in #23708. I intend to do more, but I don't want to make the PR too large.
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/format_foreign.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsyntax_ext/format_foreign.rs b/src/libsyntax_ext/format_foreign.rs index 0476d7d4fcc..e95c6f2e124 100644 --- a/src/libsyntax_ext/format_foreign.rs +++ b/src/libsyntax_ext/format_foreign.rs @@ -272,6 +272,11 @@ pub mod printf { self.s = tail; Some(sub) } + + fn size_hint(&self) -> (usize, Option<usize>) { + // Substitutions are at least 2 characters long. + (0, Some(self.s.len() / 2)) + } } enum State { @@ -782,6 +787,10 @@ pub mod shell { None => None, } } + + fn size_hint(&self) -> (usize, Option<usize>) { + (0, Some(self.s.len())) + } } /// Parse the next substitution from the input string. |
