What changed, and why it matters
This is a small internal code cleanup in the rust-bitcoin library. It removes a hand-written wrapper type called HeaderIter and instead uses a newer built-in trait (ExactSizeEncoder) to achieve the same result. There is no user-visible behavior change and no security relevance.
No action needed. This is a benign refactor with no security implications.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit deletes the HeaderIter wrapper around EncodableByteIter
Changed components
primitives/src/block.rsHeader::fmt Display implementationInspect captured patch +1 / −18
diff --git a/primitives/src/block.rs b/primitives/src/block.rs
index 482dfef5..bd8616e1 100644
--- a/primitives/src/block.rs
+++ b/primitives/src/block.rs
@@ -517,7 +517,7 @@ impl fmt::Display for Header {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use hex_unstable::{fmt_hex_exact, Case};
- fmt_hex_exact!(f, Header::SIZE, HeaderIter(EncodableByteIter::new(self)), Case::Lower)
+ fmt_hex_exact!(f, Header::SIZE, EncodableByteIter::new(self), Case::Lower)
}
}
@@ -549,23 +549,6 @@ impl fmt::Debug for Header {
}
}
-/// A wrapper around [`encoding::EncodableByteIter`]
-///
-/// This wrapper implements `ExactSizeIterator` for use with `fmt_hex_exact!`.
-#[cfg(feature = "hex")]
-struct HeaderIter<'a>(EncodableByteIter<'a, Header>);
-
-#[cfg(feature = "hex")]
-impl Iterator for HeaderIter<'_> {
- type Item = u8;
-
- fn next(&mut self) -> Option<Self::Item> { self.0.next() }
-
- fn size_hint(&self) -> (usize, Option<usize>) { (Header::SIZE, Some(Header::SIZE)) }
-}
-#[cfg(feature = "hex")]
-impl ExactSizeIterator for HeaderIter<'_> {}
-
/// An error that occurs during parsing of a [`Header`] from a hex string.
#[cfg(all(feature = "hex", feature = "alloc"))]
pub struct ParseHeaderError(crate::ParsePrimitiveError<Header>);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.