Skip to content

Commit e6802d1

Browse files
Fmt Botgithub-actions[bot]
Fmt Bot
authored andcommitted
2025-05-18 automated rustfmt nightly
1 parent 11ceadb commit e6802d1

File tree

7 files changed

+20
-18
lines changed

7 files changed

+20
-18
lines changed

bitcoin/src/blockdata/script/builder.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ impl Builder {
2323

2424
/// Constructs a new empty script builder with at least the specified capacity.
2525
#[inline]
26-
pub fn with_capacity(capacity: usize) -> Self { Builder(ScriptBuf::with_capacity(capacity), None) }
26+
pub fn with_capacity(capacity: usize) -> Self {
27+
Builder(ScriptBuf::with_capacity(capacity), None)
28+
}
2729

2830
/// Returns the length in bytes of the script.
2931
pub fn len(&self) -> usize { self.0.len() }

bitcoin/src/blockdata/transaction.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use hashes::sha256d;
1616
use internals::{compact_size, write_err, ToU64};
1717
use io::{BufRead, Write};
1818
use primitives::Sequence;
19+
use units::NumOpResult;
1920

2021
use super::Weight;
2122
use crate::consensus::{self, encode, Decodable, Encodable};
@@ -27,7 +28,6 @@ use crate::script::{Script, ScriptBuf, ScriptExt as _, ScriptExtPriv as _};
2728
use crate::sighash::{EcdsaSighashType, TapSighashType};
2829
use crate::witness::Witness;
2930
use crate::{Amount, FeeRate, SignedAmount};
30-
use units::NumOpResult;
3131

3232
#[rustfmt::skip] // Keep public re-exports separate.
3333
#[doc(inline)]
@@ -786,10 +786,7 @@ pub fn effective_value(
786786
) -> NumOpResult<SignedAmount> {
787787
let weight = input_weight_prediction.total_weight();
788788

789-
fee_rate
790-
.to_fee(weight)
791-
.map(Amount::to_signed)
792-
.and_then(|fee| value.to_signed() - fee) // Cannot overflow.
789+
fee_rate.to_fee(weight).map(Amount::to_signed).and_then(|fee| value.to_signed() - fee) // Cannot overflow.
793790
}
794791

795792
/// Predicts the weight of a to-be-constructed transaction.
@@ -1943,7 +1940,7 @@ mod tests {
19431940
// needless_borrows_for_generic_args incorrecctly identifies &[] as a needless borrow
19441941
#[allow(clippy::needless_borrows_for_generic_args)]
19451942
fn weight_prediction_new() {
1946-
let p2wpkh_max = InputWeightPrediction::new(0, [72,33]);
1943+
let p2wpkh_max = InputWeightPrediction::new(0, [72, 33]);
19471944
assert_eq!(p2wpkh_max.script_size, 1);
19481945
assert_eq!(p2wpkh_max.witness_size, 108);
19491946
assert_eq!(p2wpkh_max.total_weight(), Weight::from_wu(272));

bitcoin/src/psbt/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -852,11 +852,11 @@ impl GetKey for $map<PublicKey, PrivateKey> {
852852
KeyRequest::XOnlyPubkey(xonly) => {
853853
let pubkey_even = xonly.public_key(secp256k1::Parity::Even);
854854
let key = self.get(&pubkey_even).cloned();
855-
855+
856856
if key.is_some() {
857857
return Ok(key);
858858
}
859-
859+
860860
let pubkey_odd = xonly.public_key(secp256k1::Parity::Odd);
861861
if let Some(priv_key) = self.get(&pubkey_odd).copied() {
862862
let negated_priv_key = priv_key.negate();
@@ -889,18 +889,18 @@ impl GetKey for $map<XOnlyPublicKey, PrivateKey> {
889889
KeyRequest::XOnlyPubkey(xonly) => Ok(self.get(xonly).cloned()),
890890
KeyRequest::Pubkey(pk) => {
891891
let (xonly, parity) = pk.inner.x_only_public_key();
892-
892+
893893
if let Some(mut priv_key) = self.get(&XOnlyPublicKey::from(xonly)).cloned() {
894894
let computed_pk = priv_key.public_key(&secp);
895895
let (_, computed_parity) = computed_pk.inner.x_only_public_key();
896-
896+
897897
if computed_parity != parity {
898898
priv_key = priv_key.negate();
899899
}
900-
900+
901901
return Ok(Some(priv_key));
902902
}
903-
903+
904904
Ok(None)
905905
},
906906
KeyRequest::Bip32(_) => Err(GetKeyError::NotSupported),

units/src/fee_rate/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ crate::internal_macros::impl_op_for_references! {
161161

162162
impl ops::Div<NonZeroU64> for FeeRate {
163163
type Output = FeeRate;
164-
164+
165165
fn div(self, rhs: NonZeroU64) -> Self::Output{ Self::from_sat_per_kwu(self.to_sat_per_kwu() / rhs.get()) }
166166
}
167167
}
@@ -204,9 +204,10 @@ impl<'a> Arbitrary<'a> for FeeRate {
204204

205205
#[cfg(test)]
206206
mod tests {
207-
use super::*;
208207
use core::num::NonZeroU64;
209208

209+
use super::*;
210+
210211
#[test]
211212
fn sanity_check() {
212213
let fee_rate: u64 = u64::from(FeeRate::from_sat_per_kwu(100));

units/src/result.rs

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ pub enum NumOpResult<T> {
8888
}
8989

9090
impl<T> NumOpResult<T> {
91-
9291
/// Maps a `NumOpResult<T>` to `NumOpResult<U>` by applying a function to a
9392
/// contained [`NumOpResult::Valid`] value, leaving a [`NumOpResult::Error`] value untouched.
9493
///

units/src/weight.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,10 @@ impl<'a> Arbitrary<'a> for Weight {
293293

294294
#[cfg(test)]
295295
mod tests {
296-
use super::*;
297296
use core::num::NonZeroU64;
298297

298+
use super::*;
299+
299300
const ONE: Weight = Weight::from_wu(1);
300301
const TWO: Weight = Weight::from_wu(2);
301302
const FOUR: Weight = Weight::from_wu(4);

units/tests/serde.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
use bincode::serialize;
99
use bitcoin_units::locktime::{absolute, relative};
10-
use bitcoin_units::{amount, fee_rate, Amount, BlockHeight, BlockInterval, FeeRate, SignedAmount, Weight};
10+
use bitcoin_units::{
11+
amount, fee_rate, Amount, BlockHeight, BlockInterval, FeeRate, SignedAmount, Weight,
12+
};
1113
use serde::{Deserialize, Serialize};
1214

1315
/// A struct that includes all the types that implement or support `serde` traits.

0 commit comments

Comments
 (0)