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.
This commit is contained in:
Tobin C. Harding 2024-07-11 13:40:31 +10:00
parent 5941008733
commit 9efe4cea9d
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 16 additions and 16 deletions

View File

@ -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<I: SliceIndex<[u8]>> Index<I> 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<Self, Self::Err> { 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<I: SliceIndex<[u8]>> Index<I> 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<Self, Self::Err> { hex::FromHex::from_hex(s) }
}
impl hex::FromHex for Midstate {
type Error = hex::HexToArrayError;