Skip to content

Commit d54524f

Browse files
Fmt Botgithub-actions[bot]
Fmt Bot
authored andcommitted
2025-03-09 automated rustfmt nightly
1 parent 86266d2 commit d54524f

File tree

16 files changed

+53
-38
lines changed

16 files changed

+53
-38
lines changed

bitcoin/src/blockdata/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ pub use self::{
2121

2222
/// Implements `FeeRate` and assoctiated features.
2323
pub mod fee_rate {
24-
/// Re-export everything from the [`units::fee_rate`] module.
25-
pub use units::fee_rate::FeeRate;
2624
#[cfg(feature = "serde")]
2725
pub use units::fee_rate::serde;
26+
/// Re-export everything from the [`units::fee_rate`] module.
27+
pub use units::fee_rate::FeeRate;
2828
}
2929

3030
/// Provides absolute and relative locktimes.

bitcoin/src/blockdata/script/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::address::script_pubkey::{
88
};
99
use crate::consensus::encode::{deserialize, serialize};
1010
use crate::crypto::key::{PublicKey, XOnlyPublicKey};
11-
use crate::{Amount, FeeRate, opcodes};
11+
use crate::{opcodes, Amount, FeeRate};
1212

1313
#[test]
1414
#[rustfmt::skip]

bitcoin/src/crypto/key.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ impl PrivateKey {
462462
/// Deserializes a private key from a byte array.
463463
pub fn from_byte_array(
464464
data: [u8; 32],
465-
network: impl Into<NetworkKind>
465+
network: impl Into<NetworkKind>,
466466
) -> Result<PrivateKey, secp256k1::Error> {
467467
Ok(PrivateKey::new(secp256k1::SecretKey::from_byte_array(&data)?, network))
468468
}

bitcoin/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,7 @@ pub use crate::{
164164
blockdata::script::witness_program::{self, WitnessProgram},
165165
blockdata::script::witness_version::{self, WitnessVersion},
166166
// These modules also re-export all the respective `primitives` types.
167-
blockdata::{
168-
block, constants, fee_rate, locktime, script, transaction, weight, witness,
169-
},
167+
blockdata::{block, constants, fee_rate, locktime, script, transaction, weight, witness},
170168
};
171169

172170
#[rustfmt::skip]

bitcoin/src/psbt/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl Psbt {
135135
/// An alias for [`extract_tx_fee_rate_limit`].
136136
///
137137
/// [`extract_tx_fee_rate_limit`]: Psbt::extract_tx_fee_rate_limit
138-
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
138+
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
139139
pub fn extract_tx(self) -> Result<Transaction, ExtractTxError> {
140140
self.internal_extract_tx_with_fee_rate_limit(Self::DEFAULT_MAX_FEE_RATE)
141141
}
@@ -147,7 +147,7 @@ impl Psbt {
147147
/// [`ExtractTxError`] variants will contain either the [`Psbt`] itself or the [`Transaction`]
148148
/// that was extracted. These can be extracted from the Errors in order to recover.
149149
/// See the error documentation for info on the variants. In general, it covers large fees.
150-
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
150+
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
151151
pub fn extract_tx_fee_rate_limit(self) -> Result<Transaction, ExtractTxError> {
152152
self.internal_extract_tx_with_fee_rate_limit(Self::DEFAULT_MAX_FEE_RATE)
153153
}
@@ -159,7 +159,7 @@ impl Psbt {
159159
/// See [`extract_tx`].
160160
///
161161
/// [`extract_tx`]: Psbt::extract_tx
162-
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
162+
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
163163
pub fn extract_tx_with_fee_rate_limit(
164164
self,
165165
max_fee_rate: FeeRate,
@@ -187,7 +187,7 @@ impl Psbt {
187187
}
188188

189189
#[inline]
190-
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
190+
#[allow(clippy::result_large_err)] // The PSBT returned in `SendingToomuch` is large.
191191
fn internal_extract_tx_with_fee_rate_limit(
192192
self,
193193
max_fee_rate: FeeRate,

bitcoin/src/psbt/serialize.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,8 @@ impl Serialize for XOnlyPublicKey {
260260

261261
impl Deserialize for XOnlyPublicKey {
262262
fn deserialize(bytes: &[u8]) -> Result<Self, Error> {
263-
XOnlyPublicKey::from_byte_array(
264-
bytes.try_into().map_err(|_| Error::InvalidXOnlyPublicKey)?,
265-
)
266-
.map_err(|_| Error::InvalidXOnlyPublicKey)
263+
XOnlyPublicKey::from_byte_array(bytes.try_into().map_err(|_| Error::InvalidXOnlyPublicKey)?)
264+
.map_err(|_| Error::InvalidXOnlyPublicKey)
267265
}
268266
}
269267

bitcoin/src/taproot/merkle_branch.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ impl TaprootMerkleBranch {
5252
} else if node_hashes.len() > TAPROOT_CONTROL_MAX_NODE_COUNT {
5353
Err(InvalidMerkleTreeDepthError(sl.len() / TAPROOT_CONTROL_NODE_SIZE).into())
5454
} else {
55-
let inner = node_hashes
56-
.iter()
57-
.copied()
58-
.map(TapNodeHash::from_byte_array)
59-
.collect();
55+
let inner = node_hashes.iter().copied().map(TapNodeHash::from_byte_array).collect();
6056

6157
Ok(TaprootMerkleBranch(inner))
6258
}

hashes/src/ripemd160/crypto.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: CC0-1.0
22

33
use internals::slice::SliceExt;
4+
45
use super::{HashEngine, BLOCK_SIZE};
56

67
#[cfg(feature = "small-hash")]

hashes/src/sha1/crypto.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: CC0-1.0
22

33
use internals::slice::SliceExt;
4+
45
use super::{HashEngine, BLOCK_SIZE};
56

67
impl HashEngine {

hashes/src/sha256/crypto.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use core::arch::x86::*;
66
use core::arch::x86_64::*;
77

88
use internals::slice::SliceExt;
9+
910
use super::{HashEngine, Midstate, BLOCK_SIZE};
1011

1112
#[allow(non_snake_case)]

hashes/src/sha256/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ mod crypto;
99
mod tests;
1010

1111
use core::{cmp, convert, fmt};
12+
1213
use internals::slice::SliceExt;
1314

1415
use crate::{incomplete_block_len, sha256d, HashEngine as _};
@@ -80,7 +81,8 @@ impl HashEngine {
8081
/// Please see docs on [`Midstate`] before using this function.
8182
pub fn from_midstate(midstate: Midstate) -> HashEngine {
8283
let mut ret = [0; 8];
83-
for (ret_val, midstate_bytes) in ret.iter_mut().zip(midstate.as_ref().bitcoin_as_chunks().0) {
84+
for (ret_val, midstate_bytes) in ret.iter_mut().zip(midstate.as_ref().bitcoin_as_chunks().0)
85+
{
8486
*ret_val = u32::from_be_bytes(*midstate_bytes);
8587
}
8688

hashes/src/sha512/crypto.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: CC0-1.0
22

33
use internals::slice::SliceExt;
4+
45
use super::{HashEngine, BLOCK_SIZE};
56

67
#[allow(non_snake_case)]

internals/src/slice.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ pub trait SliceExt {
2323
/// let mut slice = [1, 2, 3];
2424
/// let fail = slice.as_chunks_mut::<0>();
2525
/// ```
26-
fn bitcoin_as_chunks_mut<const N: usize>(&mut self) -> (&mut [[Self::Item; N]], &mut [Self::Item]);
26+
fn bitcoin_as_chunks_mut<const N: usize>(
27+
&mut self,
28+
) -> (&mut [[Self::Item; N]], &mut [Self::Item]);
2729
}
2830

2931
impl<T> SliceExt for [T] {
@@ -40,11 +42,15 @@ impl<T> SliceExt for [T] {
4042
// we're merely casting, so no aliasing issues here
4143
// arrays of T have same alignment as T
4244
// the resulting slice points within the obtained slice as was computed above
43-
let left = unsafe { core::slice::from_raw_parts(left.as_ptr().cast::<[Self::Item; N]>(), chunks_count) };
45+
let left = unsafe {
46+
core::slice::from_raw_parts(left.as_ptr().cast::<[Self::Item; N]>(), chunks_count)
47+
};
4448
(left, right)
4549
}
4650

47-
fn bitcoin_as_chunks_mut<const N: usize>(&mut self) -> (&mut [[Self::Item; N]], &mut [Self::Item]) {
51+
fn bitcoin_as_chunks_mut<const N: usize>(
52+
&mut self,
53+
) -> (&mut [[Self::Item; N]], &mut [Self::Item]) {
4854
#[allow(clippy::let_unit_value)]
4955
let _ = Hack::<N>::IS_NONZERO;
5056

@@ -55,15 +61,22 @@ impl<T> SliceExt for [T] {
5561
// we're merely casting, so no aliasing issues here
5662
// arrays of T have same alignment as T
5763
// the resulting slice points within the obtained slice as was computed above
58-
let left = unsafe { core::slice::from_raw_parts_mut(left.as_mut_ptr().cast::<[Self::Item; N]>(), chunks_count) };
64+
let left = unsafe {
65+
core::slice::from_raw_parts_mut(
66+
left.as_mut_ptr().cast::<[Self::Item; N]>(),
67+
chunks_count,
68+
)
69+
};
5970
(left, right)
6071
}
6172
}
6273

6374
struct Hack<const N: usize>;
6475

6576
impl<const N: usize> Hack<N> {
66-
const IS_NONZERO: () = { assert!(N != 0); };
77+
const IS_NONZERO: () = {
78+
assert!(N != 0);
79+
};
6780
}
6881

6982
#[cfg(test)]

primitives/src/opcodes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! all of the opcodes for that language.
77
88
#![allow(non_camel_case_types)]
9-
#![allow(dead_code)] // This module is private and is duplicated in `bitcoin`.
9+
#![allow(dead_code)] // This module is private and is duplicated in `bitcoin`.
1010

1111
use core::fmt;
1212

units/src/amount/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl Denomination {
113113
Denomination::MicroBitcoin => -2,
114114
Denomination::Bit => -2,
115115
Denomination::Satoshi => 0,
116-
Denomination::_DoNotUse(infallible) => match infallible {}
116+
Denomination::_DoNotUse(infallible) => match infallible {},
117117
}
118118
}
119119

@@ -126,7 +126,7 @@ impl Denomination {
126126
Denomination::MicroBitcoin => "uBTC",
127127
Denomination::Bit => "bits",
128128
Denomination::Satoshi => "satoshi",
129-
Denomination::_DoNotUse(infallible) => match infallible {}
129+
Denomination::_DoNotUse(infallible) => match infallible {},
130130
}
131131
}
132132

units/src/amount/tests.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -1015,11 +1015,19 @@ fn sum_amounts() {
10151015
assert_eq!([].iter().sum::<NumOpResult<Amount>>(), Amount::ZERO.into());
10161016
assert_eq!([].iter().sum::<NumOpResult<SignedAmount>>(), SignedAmount::ZERO.into());
10171017

1018-
let results = [NumOpResult::Valid(sat(42)), NumOpResult::Valid(sat(1337)), NumOpResult::Valid(sat(21))];
1018+
let results =
1019+
[NumOpResult::Valid(sat(42)), NumOpResult::Valid(sat(1337)), NumOpResult::Valid(sat(21))];
10191020
assert_eq!(results.iter().sum::<NumOpResult<Amount>>(), NumOpResult::Valid(sat(1400)));
10201021

1021-
let signed_results = [NumOpResult::Valid(ssat(42)), NumOpResult::Valid(ssat(1337)), NumOpResult::Valid(ssat(21))];
1022-
assert_eq!(signed_results.iter().sum::<NumOpResult<SignedAmount>>(), NumOpResult::Valid(ssat(1400)));
1022+
let signed_results = [
1023+
NumOpResult::Valid(ssat(42)),
1024+
NumOpResult::Valid(ssat(1337)),
1025+
NumOpResult::Valid(ssat(21)),
1026+
];
1027+
assert_eq!(
1028+
signed_results.iter().sum::<NumOpResult<SignedAmount>>(),
1029+
NumOpResult::Valid(ssat(1400))
1030+
);
10231031

10241032
let amounts = [sat(42), sat(1337), sat(21)];
10251033
assert_eq!(
@@ -1303,9 +1311,7 @@ fn unsigned_amount_div_by_amount() {
13031311

13041312
#[test]
13051313
#[should_panic(expected = "attempt to divide by zero")]
1306-
fn unsigned_amount_div_by_amount_zero() {
1307-
let _ = Amount::from_sat(1897) / Amount::ZERO;
1308-
}
1314+
fn unsigned_amount_div_by_amount_zero() { let _ = Amount::from_sat(1897) / Amount::ZERO; }
13091315

13101316
#[test]
13111317
fn signed_amount_div_by_amount() {
@@ -1321,9 +1327,7 @@ fn signed_amount_div_by_amount() {
13211327

13221328
#[test]
13231329
#[should_panic(expected = "attempt to divide by zero")]
1324-
fn signed_amount_div_by_amount_zero() {
1325-
let _ = SignedAmount::from_sat(1897) / SignedAmount::ZERO;
1326-
}
1330+
fn signed_amount_div_by_amount_zero() { let _ = SignedAmount::from_sat(1897) / SignedAmount::ZERO; }
13271331

13281332
#[test]
13291333
fn check_const() {

0 commit comments

Comments
 (0)