1
Fork 0

Implement some trivial size_hints for various iterators

This also implements ExactSizeIterator where applicable.

Addresses most of the Iterator traits mentioned in #23708.
This commit is contained in:
Phlosioneer 2018-03-20 05:33:59 -04:00
parent 6bfa7d02d6
commit 619003d1d4
13 changed files with 102 additions and 0 deletions

View file

@ -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.