From 191897f9ea9e3a147fdc05325c3c77ae25a13c4c Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 8 Aug 2024 09:38:45 +1000 Subject: [PATCH] Manually format Run `rustfmt` and manually fix the places where comments are moved to the wrong place. --- bitcoin/src/blockdata/script/owned.rs | 3 ++- hashes/src/internal_macros.rs | 1 - hashes/src/lib.rs | 10 ++++------ hashes/src/sha256t.rs | 5 +++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/bitcoin/src/blockdata/script/owned.rs b/bitcoin/src/blockdata/script/owned.rs index d8a80dea0..7a639f472 100644 --- a/bitcoin/src/blockdata/script/owned.rs +++ b/bitcoin/src/blockdata/script/owned.rs @@ -113,7 +113,8 @@ impl ScriptBuf { self.0.push((n % 0x100) as u8); self.0.push((n / 0x100) as u8); } - n => { // `PushBytes` enforces len < 0x100000000 + // `PushBytes` enforces len < 0x100000000 + n => { self.0.push(opcodes::Ordinary::OP_PUSHDATA4.to_u8()); self.0.push((n % 0x100) as u8); self.0.push(((n / 0x100) % 0x100) as u8); diff --git a/hashes/src/internal_macros.rs b/hashes/src/internal_macros.rs index bf0157d82..0b66e4185 100644 --- a/hashes/src/internal_macros.rs +++ b/hashes/src/internal_macros.rs @@ -197,7 +197,6 @@ macro_rules! hash_type { ::hash_byte_chunks(byte_slices) } - /// Hashes the entire contents of the `reader`. #[cfg(feature = "bitcoin-io")] pub fn hash_reader(reader: &mut R) -> Result { diff --git a/hashes/src/lib.rs b/hashes/src/lib.rs index 3994cf649..fb78fdbd7 100644 --- a/hashes/src/lib.rs +++ b/hashes/src/lib.rs @@ -247,8 +247,9 @@ pub trait GeneralHash: Hash { let bytes = reader.fill_buf()?; let read = bytes.len(); - if read == 0 { // Empty slice means EOF. - break + // Empty slice means EOF. + if read == 0 { + break; } engine.input(bytes); @@ -352,9 +353,6 @@ mod tests { #[test] fn hash_reader() { let mut reader: &[u8] = b"hello"; - assert_eq!( - sha256::Hash::hash_reader(&mut reader).unwrap(), - sha256::Hash::hash(b"hello"), - ) + assert_eq!(sha256::Hash::hash_reader(&mut reader).unwrap(), sha256::Hash::hash(b"hello"),) } } diff --git a/hashes/src/sha256t.rs b/hashes/src/sha256t.rs index 61c769de2..2a0a24870 100644 --- a/hashes/src/sha256t.rs +++ b/hashes/src/sha256t.rs @@ -104,8 +104,9 @@ where let bytes = reader.fill_buf()?; let read = bytes.len(); - if read == 0 { // Empty slice means EOF. - break + // Empty slice means EOF. + if read == 0 { + break; } engine.input(bytes);