Skip to content

Commit 2495b06

Browse files
committed
Merge #114: Call through to inner size_hint
2a12d2e Call through to inner size_hint (Tobin C. Harding) 0336da0 Remove unnecessary whitespace (Tobin C. Harding) Pull request description: Currently our `size_hint` methods are calling `len` (from `ExactSizeIterator`) which is incorrect. We should in fact call `size_hint` on the inner iterator. ACKs for top commit: apoelstra: ACK 2a12d2e clarkmoody: ACK 2a12d2e Tree-SHA512: 75c69fa306c76045f465813e9b696788ff72899b6cf9f7347489a12f9c31b8baba0f1dd5067edd5c7ad117e3f82b1491555b91cc628ed7816a4135e24e6f000a
2 parents 7a629c6 + 2a12d2e commit 2495b06

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/primitives/hrp.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -207,8 +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-
211-
fn size_hint(&self) -> (usize, Option<usize>) { (self.len(), Some(self.len())) }
210+
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
212211
}
213212

214213
impl<'b> ExactSizeIterator for ByteIter<'b> {
@@ -231,8 +230,7 @@ pub struct CharIter<'b> {
231230
impl<'b> Iterator for CharIter<'b> {
232231
type Item = char;
233232
fn next(&mut self) -> Option<char> { self.iter.next().map(Into::into) }
234-
235-
fn size_hint(&self) -> (usize, Option<usize>) { (self.len(), Some(self.len())) }
233+
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
236234
}
237235

238236
impl<'b> ExactSizeIterator for CharIter<'b> {
@@ -255,8 +253,7 @@ impl<'b> Iterator for LowercaseByteIter<'b> {
255253
fn next(&mut self) -> Option<u8> {
256254
self.iter.next().map(|b| if is_ascii_uppercase(b) { b | 32 } else { b })
257255
}
258-
259-
fn size_hint(&self) -> (usize, Option<usize>) { (self.len(), Some(self.len())) }
256+
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
260257
}
261258

262259
impl<'b> ExactSizeIterator for LowercaseByteIter<'b> {
@@ -279,8 +276,7 @@ pub struct LowercaseCharIter<'b> {
279276
impl<'b> Iterator for LowercaseCharIter<'b> {
280277
type Item = char;
281278
fn next(&mut self) -> Option<char> { self.iter.next().map(Into::into) }
282-
283-
fn size_hint(&self) -> (usize, Option<usize>) { (self.len(), Some(self.len())) }
279+
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
284280
}
285281

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

0 commit comments

Comments
 (0)