Skip to content

Commit 2a12d2e

Browse files
committed
Call through to inner size_hint
Currently our `size_hint` methods are calling `len` (from `ExactSizeIterator`) which is incorrect. We should in fact call `size_hint` on the inner iterator.
1 parent 0336da0 commit 2a12d2e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/primitives/hrp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ pub struct ByteIter<'b> {
207207
impl<'b> Iterator for ByteIter<'b> {
208208
type Item = u8;
209209
fn next(&mut self) -> Option<u8> { self.iter.next().copied() }
210-
fn size_hint(&self) -> (usize, Option<usize>) { (self.len(), Some(self.len())) }
210+
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
211211
}
212212

213213
impl<'b> ExactSizeIterator for ByteIter<'b> {
@@ -230,7 +230,7 @@ pub struct CharIter<'b> {
230230
impl<'b> Iterator for CharIter<'b> {
231231
type Item = char;
232232
fn next(&mut self) -> Option<char> { self.iter.next().map(Into::into) }
233-
fn size_hint(&self) -> (usize, Option<usize>) { (self.len(), Some(self.len())) }
233+
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
234234
}
235235

236236
impl<'b> ExactSizeIterator for CharIter<'b> {
@@ -253,7 +253,7 @@ impl<'b> Iterator for LowercaseByteIter<'b> {
253253
fn next(&mut self) -> Option<u8> {
254254
self.iter.next().map(|b| if is_ascii_uppercase(b) { b | 32 } else { b })
255255
}
256-
fn size_hint(&self) -> (usize, Option<usize>) { (self.len(), Some(self.len())) }
256+
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
257257
}
258258

259259
impl<'b> ExactSizeIterator for LowercaseByteIter<'b> {
@@ -276,7 +276,7 @@ pub struct LowercaseCharIter<'b> {
276276
impl<'b> Iterator for LowercaseCharIter<'b> {
277277
type Item = char;
278278
fn next(&mut self) -> Option<char> { self.iter.next().map(Into::into) }
279-
fn size_hint(&self) -> (usize, Option<usize>) { (self.len(), Some(self.len())) }
279+
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
280280
}
281281

282282
impl<'b> ExactSizeIterator for LowercaseCharIter<'b> {

0 commit comments

Comments
 (0)