Actually put the encoder trait impls first
What changed, and why it matters
This commit simply reorders code in a single Rust source file. It moves the implementation of encoding/decoding traits above the helper 'encoder newtype' struct so the file matches the author's earlier stated intention. There is no functional change, no bug fix, and no security relevance.
No action required; this is a non-functional code-style/cleanup change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In primitives/src/hash_types/block_hash.rs, the BlockHash Encodable/Decodable trait impls are moved before the encoding::encoder_newtype_exact! macro invocation that defines BlockHashEncoder. The diff is a pure reordering of existing code blocks (+5/-5 identical lines). No logic, signatures, or behavior changes.
Changed components
primitives/src/hash_types/block_hash.rsInspect captured patch +5 / −5
diff --git a/primitives/src/hash_types/block_hash.rs b/primitives/src/hash_types/block_hash.rs
index 8478a5b3..65684396 100644
--- a/primitives/src/hash_types/block_hash.rs
+++ b/primitives/src/hash_types/block_hash.rs
@@ -30,11 +30,6 @@ type Inner = sha256d::Hash;
include!("./generic.rs");
-encoding::encoder_newtype_exact! {
- /// The encoder for the [`BlockHash`] type.
- pub struct BlockHashEncoder<'e>(encoding::ArrayRefEncoder<'e, 32>);
-}
-
impl encoding::Encodable for BlockHash {
type Encoder<'e> = BlockHashEncoder<'e>;
#[inline]
@@ -51,6 +46,11 @@ impl encoding::Decodable for BlockHash {
fn decoder() -> Self::Decoder { BlockHashDecoder(encoding::ArrayDecoder::<32>::new()) }
}
+encoding::encoder_newtype_exact! {
+ /// The encoder for the [`BlockHash`] type.
+ pub struct BlockHashEncoder<'e>(encoding::ArrayRefEncoder<'e, 32>);
+}
+
/// The decoder for the [`BlockHash`] type.
pub struct BlockHashDecoder(encoding::ArrayDecoder<32>);
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.