Skip to content

Commit

Permalink
Merge #114: Call through to inner size_hint
Browse files Browse the repository at this point in the history
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
  • Loading branch information
apoelstra committed Jul 9, 2023
2 parents 7a629c6 + 2a12d2e commit 2495b06
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/primitives/hrp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ pub struct ByteIter<'b> {
impl<'b> Iterator for ByteIter<'b> {
type Item = u8;
fn next(&mut self) -> Option<u8> { self.iter.next().copied() }

fn size_hint(&self) -> (usize, Option<usize>) { (self.len(), Some(self.len())) }
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
}

impl<'b> ExactSizeIterator for ByteIter<'b> {
Expand All @@ -231,8 +230,7 @@ pub struct CharIter<'b> {
impl<'b> Iterator for CharIter<'b> {
type Item = char;
fn next(&mut self) -> Option<char> { self.iter.next().map(Into::into) }

fn size_hint(&self) -> (usize, Option<usize>) { (self.len(), Some(self.len())) }
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
}

impl<'b> ExactSizeIterator for CharIter<'b> {
Expand All @@ -255,8 +253,7 @@ impl<'b> Iterator for LowercaseByteIter<'b> {
fn next(&mut self) -> Option<u8> {
self.iter.next().map(|b| if is_ascii_uppercase(b) { b | 32 } else { b })
}

fn size_hint(&self) -> (usize, Option<usize>) { (self.len(), Some(self.len())) }
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
}

impl<'b> ExactSizeIterator for LowercaseByteIter<'b> {
Expand All @@ -279,8 +276,7 @@ pub struct LowercaseCharIter<'b> {
impl<'b> Iterator for LowercaseCharIter<'b> {
type Item = char;
fn next(&mut self) -> Option<char> { self.iter.next().map(Into::into) }

fn size_hint(&self) -> (usize, Option<usize>) { (self.len(), Some(self.len())) }
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
}

impl<'b> ExactSizeIterator for LowercaseCharIter<'b> {
Expand Down

0 comments on commit 2495b06

Please sign in to comment.