From cfc5aa5cbd690a9f82bd27973c871c7751805d55 Mon Sep 17 00:00:00 2001 From: Angel Leon Date: Wed, 27 Sep 2023 19:14:49 -0600 Subject: [PATCH] Nibbles nits (#285) Signed-off-by: JacobEverly <112036223+JacobEverly@users.noreply.github.com> --- firewood/src/nibbles.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/firewood/src/nibbles.rs b/firewood/src/nibbles.rs index d918fb517..8de0865eb 100644 --- a/firewood/src/nibbles.rs +++ b/firewood/src/nibbles.rs @@ -84,7 +84,7 @@ impl<'a, const LEADING_ZEROES: usize> Nibbles<'a, LEADING_ZEROES> { } } -/// An interator returned by [Nibbles::into_iter] +/// An iterator returned by [Nibbles::into_iter] /// See their documentation for details. #[derive(Clone, Debug)] pub struct NibblesIterator<'a, const LEADING_ZEROES: usize> { @@ -107,15 +107,15 @@ impl<'a, const LEADING_ZEROES: usize> Iterator for NibblesIterator<'a, LEADING_Z result } - fn nth(&mut self, n: usize) -> Option { - self.head += std::cmp::min(n, self.tail - self.head); - self.next() - } - fn size_hint(&self) -> (usize, Option) { let remaining = self.tail - self.head; (remaining, Some(remaining)) } + + fn nth(&mut self, n: usize) -> Option { + self.head += std::cmp::min(n, self.tail - self.head); + self.next() + } } impl<'a, const LEADING_ZEROES: usize> NibblesIterator<'a, LEADING_ZEROES> { @@ -155,7 +155,7 @@ mod test { } #[test] - fn leadingzero_nibbles_index() { + fn leading_zero_nibbles_index() { let nib = Nibbles::<1>(&TEST_BYTES); let expected = [0u8, 0xd, 0xe, 0xa, 0xd, 0xb, 0xe, 0xe, 0xf]; for v in expected.into_iter().enumerate() {