From 9efe4cea9d75733032ad47762f458b8ab7e6c6e3 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 11 Jul 2024 13:40:31 +1000 Subject: [PATCH] Move impl block under struct Put the impl block for `Midstate` under the struct, as is customary. (Note the diff shows moving some other code around the impl block not the impl block itself.) Code move only. --- hashes/src/sha256.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/hashes/src/sha256.rs b/hashes/src/sha256.rs index 68fa277c7..e6bb03f12 100644 --- a/hashes/src/sha256.rs +++ b/hashes/src/sha256.rs @@ -123,22 +123,6 @@ impl Hash { #[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)] pub struct Midstate(pub [u8; 32]); -crate::internal_macros::arr_newtype_fmt_impl!(Midstate, 32); -serde_impl!(Midstate, 32); -borrow_slice_impl!(Midstate); - -impl> Index for Midstate { - type Output = I::Output; - - #[inline] - fn index(&self, index: I) -> &Self::Output { &self.0[index] } -} - -impl core::str::FromStr for Midstate { - type Err = hex::HexToArrayError; - fn from_str(s: &str) -> Result { hex::FromHex::from_hex(s) } -} - impl Midstate { /// Length of the midstate, in bytes. const LEN: usize = 32; @@ -183,6 +167,22 @@ impl Midstate { } } +crate::internal_macros::arr_newtype_fmt_impl!(Midstate, 32); +serde_impl!(Midstate, 32); +borrow_slice_impl!(Midstate); + +impl> Index for Midstate { + type Output = I::Output; + + #[inline] + fn index(&self, index: I) -> &Self::Output { &self.0[index] } +} + +impl core::str::FromStr for Midstate { + type Err = hex::HexToArrayError; + fn from_str(s: &str) -> Result { hex::FromHex::from_hex(s) } +} + impl hex::FromHex for Midstate { type Error = hex::HexToArrayError;