From f1733309e0b0721f39ea3575f1dd7973d7827483 Mon Sep 17 00:00:00 2001 From: Fmt Bot Date: Sun, 13 Oct 2024 01:20:28 +0000 Subject: [PATCH] 2024-10-13 automated rustfmt nightly --- base58/src/lib.rs | 5 +++-- bitcoin/src/blockdata/block.rs | 11 ++++------- hashes/src/serde_macros.rs | 5 +---- primitives/src/block.rs | 4 ++-- units/src/amount.rs | 14 +++++--------- 5 files changed, 15 insertions(+), 24 deletions(-) diff --git a/base58/src/lib.rs b/base58/src/lib.rs index 75e99466d..f819d8d97 100644 --- a/base58/src/lib.rs +++ b/base58/src/lib.rs @@ -113,8 +113,9 @@ pub fn decode_check(data: &str) -> Result, Error> { } let check_start = ret.len() - 4; - let hash_check = - sha256d::Hash::hash(&ret[..check_start]).as_byte_array()[..4].try_into().expect("4 byte slice"); + let hash_check = sha256d::Hash::hash(&ret[..check_start]).as_byte_array()[..4] + .try_into() + .expect("4 byte slice"); let data_check = ret[check_start..].try_into().expect("4 byte slice"); let expected = u32::from_le_bytes(hash_check); diff --git a/bitcoin/src/blockdata/block.rs b/bitcoin/src/blockdata/block.rs index 255409113..3d90d7e6b 100644 --- a/bitcoin/src/blockdata/block.rs +++ b/bitcoin/src/blockdata/block.rs @@ -9,11 +9,11 @@ use core::fmt; +#[cfg(feature = "arbitrary")] +use arbitrary::{Arbitrary, Unstructured}; use hashes::{sha256d, HashEngine}; use internals::compact_size; use io::{BufRead, Write}; -#[cfg(feature = "arbitrary")] -use arbitrary::{Arbitrary, Unstructured}; use super::Weight; use crate::consensus::{encode, Decodable, Encodable}; @@ -411,7 +411,7 @@ impl<'a> Arbitrary<'a> for Header { merkle_root: TxMerkleNode::from_byte_array(u.arbitrary()?), time: u.arbitrary()?, bits: CompactTarget::from_consensus(u.arbitrary()?), - nonce: u.arbitrary()? + nonce: u.arbitrary()?, }) } } @@ -419,10 +419,7 @@ impl<'a> Arbitrary<'a> for Header { #[cfg(feature = "arbitrary")] impl<'a> Arbitrary<'a> for Block { fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result { - Ok(Block { - header: Header::arbitrary(u)?, - txdata: Vec::::arbitrary(u)?, - }) + Ok(Block { header: Header::arbitrary(u)?, txdata: Vec::::arbitrary(u)? }) } } diff --git a/hashes/src/serde_macros.rs b/hashes/src/serde_macros.rs index b4c867232..ff542d29a 100644 --- a/hashes/src/serde_macros.rs +++ b/hashes/src/serde_macros.rs @@ -70,10 +70,7 @@ pub mod serde_details { /// Default serialization/deserialization methods. pub trait SerdeHash where - Self: Sized - + FromStr - + fmt::Display - + crate::Hash, + Self: Sized + FromStr + fmt::Display + crate::Hash, ::Err: fmt::Display, { /// Size, in bits, of the hash. diff --git a/primitives/src/block.rs b/primitives/src/block.rs index 8b7120771..23e73bdc1 100644 --- a/primitives/src/block.rs +++ b/primitives/src/block.rs @@ -7,9 +7,9 @@ //! module describes structures and functions needed to describe //! these blocks and the blockchain. -use hashes::sha256d; #[cfg(feature = "arbitrary")] use arbitrary::{Arbitrary, Unstructured}; +use hashes::sha256d; /// Bitcoin block version number. /// @@ -102,7 +102,7 @@ impl<'a> Arbitrary<'a> for Version { 0 => Ok(Version::ONE), 1 => Ok(Version::TWO), 2 => Ok(Version::NO_SOFT_FORK_SIGNALLING), - _ => Ok(Version::from_consensus(u.arbitrary()?)) + _ => Ok(Version::from_consensus(u.arbitrary()?)), } } } diff --git a/units/src/amount.rs b/units/src/amount.rs index 4a59661b2..0f146dbb5 100644 --- a/units/src/amount.rs +++ b/units/src/amount.rs @@ -5,9 +5,6 @@ //! This module mainly introduces the [`Amount`] and [`SignedAmount`] types. //! We refer to the documentation on the types for more information. -#[cfg(feature = "alloc")] -use crate::{Weight, FeeRate}; - #[cfg(feature = "alloc")] use alloc::string::{String, ToString}; use core::cmp::Ordering; @@ -21,6 +18,9 @@ use arbitrary::{Arbitrary, Unstructured}; use internals::error::InputString; use internals::write_err; +#[cfg(feature = "alloc")] +use crate::{FeeRate, Weight}; + /// A set of denominations in which amounts can be expressed. /// /// # Accepted Denominations @@ -2242,16 +2242,12 @@ mod tests { #[test] fn amount_checked_div_by_weight() { let weight = Weight::from_kwu(1).unwrap(); - let fee_rate = Amount::from_sat(1) - .checked_div_by_weight(weight) - .unwrap(); + let fee_rate = Amount::from_sat(1).checked_div_by_weight(weight).unwrap(); // 1 sats / 1,000 wu = 1 sats/kwu assert_eq!(fee_rate, FeeRate::from_sat_per_kwu(1)); let weight = Weight::from_wu(381); - let fee_rate = Amount::from_sat(329) - .checked_div_by_weight(weight) - .unwrap(); + let fee_rate = Amount::from_sat(329).checked_div_by_weight(weight).unwrap(); // 329 sats / 381 wu = 863.5 sats/kwu // round up to 864 assert_eq!(fee_rate, FeeRate::from_sat_per_kwu(864));