Skip to content

Commit 4b2226c

Browse files
committed
Merge rust-bitcoin#4714: Automated nightly rustfmt (2025-07-20)
2e18acc 2025-07-20 automated rustfmt nightly (Fmt Bot) Pull request description: Automated nightly `rustfmt` changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action ACKs for top commit: apoelstra: ACK 2e18acc; successfully ran local tests Tree-SHA512: bc4fd8b523fbae17befe6d83c153f4730f10bb3227a9143cd903be94ccc6bd30bde45c50dc887a61b28fe475f2c53302ee054faed30aa1e83de0212e691ae510
2 parents 03c0329 + 2e18acc commit 4b2226c

File tree

7 files changed

+37
-64
lines changed

7 files changed

+37
-64
lines changed

bitcoin/src/blockdata/block.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,7 @@ mod tests {
535535
use crate::pow::test_utils::{u128_to_work, u64_to_work};
536536
use crate::script::ScriptBuf;
537537
use crate::transaction::{OutPoint, Transaction, TxIn, TxOut, Txid};
538-
use crate::{block, CompactTarget, Network, TestnetVersion};
539-
use crate::{Amount, Sequence, Witness};
538+
use crate::{block, Amount, CompactTarget, Network, Sequence, TestnetVersion, Witness};
540539

541540
#[test]
542541
fn static_vector() {

bitcoin/src/blockdata/transaction.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,17 +1175,13 @@ impl Coinbase {
11751175
///
11761176
/// This method does not validate that the transaction is actually a coinbase transaction.
11771177
/// The caller must ensure that this transaction is indeed a valid coinbase transaction.
1178-
pub fn assume_coinbase(tx: Transaction) -> Self {
1179-
Self(tx)
1180-
}
1178+
pub fn assume_coinbase(tx: Transaction) -> Self { Self(tx) }
11811179

11821180
/// Returns the first input of this coinbase transaction.
11831181
///
11841182
/// This method is infallible because a valid coinbase transaction is guaranteed
11851183
/// to have exactly one input.
1186-
pub fn first_input(&self) -> &TxIn {
1187-
&self.0.input[0]
1188-
}
1184+
pub fn first_input(&self) -> &TxIn { &self.0.input[0] }
11891185

11901186
/// Returns a reference to the underlying transaction.
11911187
///
@@ -1200,17 +1196,13 @@ impl Coinbase {
12001196
pub fn into_transaction(self) -> Transaction { self.0 }
12011197

12021198
/// Computes the [`Txid`] of this coinbase transaction.
1203-
pub fn compute_txid(&self) -> Txid {
1204-
self.0.compute_txid()
1205-
}
1199+
pub fn compute_txid(&self) -> Txid { self.0.compute_txid() }
12061200

12071201
/// Returns the wtxid of this coinbase transaction.
12081202
///
12091203
/// For coinbase transactions, this is always `Wtxid::COINBASE`.
12101204
#[doc(alias = "compute_wtxid")]
1211-
pub const fn wtxid(&self) -> Wtxid {
1212-
Wtxid::COINBASE
1213-
}
1205+
pub const fn wtxid(&self) -> Wtxid { Wtxid::COINBASE }
12141206
}
12151207

12161208
mod sealed {

bitcoin/src/network/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pub enum TestnetVersion {
5959
V4,
6060
}
6161

62-
6362
/// The cryptocurrency network to act on.
6463
///
6564
/// This is an exhaustive enum, meaning that we cannot add any future networks without defining a

bitcoin/tests/network.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,32 @@ use bitcoin::network::{Network, NetworkKind, TestnetVersion};
55
#[test]
66
fn can_match_exhaustively_on_network() {
77
// Returns true if `n` is mainnet.
8-
fn is_mainnet(n: Network) -> bool {
9-
matches!(n, Network::Bitcoin)
10-
}
8+
fn is_mainnet(n: Network) -> bool { matches!(n, Network::Bitcoin) }
119

1210
assert!(is_mainnet(Network::Bitcoin));
1311
}
1412

1513
#[test]
1614
fn can_match_exhaustively_on_testnet() {
1715
// Returns true if `n` is any testnet.
18-
fn is_testnet(n: Network) -> bool {
19-
matches!(n, Network::Testnet(_))
20-
}
16+
fn is_testnet(n: Network) -> bool { matches!(n, Network::Testnet(_)) }
2117

2218
assert!(is_testnet(Network::Testnet(TestnetVersion::V3)));
2319
}
2420

2521
#[test]
2622
fn can_use_network_kind() {
2723
// Returns true if `n` is any mainnet.
28-
fn is_mainnet(n: Network) -> bool {
29-
NetworkKind::from(n).is_mainnet()
30-
}
24+
fn is_mainnet(n: Network) -> bool { NetworkKind::from(n).is_mainnet() }
3125

3226
// Returns true if `n` is a any testnet.
33-
fn is_testnet(n: Network) -> bool {
34-
!NetworkKind::from(n).is_mainnet()
35-
}
27+
fn is_testnet(n: Network) -> bool { !NetworkKind::from(n).is_mainnet() }
3628

3729
assert!(is_mainnet(Network::Bitcoin));
3830
assert!(!is_testnet(Network::Bitcoin));
3931

4032
assert!(is_testnet(Network::Testnet(TestnetVersion::V3)));
4133
assert!(!is_mainnet(Network::Testnet(TestnetVersion::V3)));
42-
4334
}
4435

4536
#[test]

primitives/src/locktime/relative.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use core::{convert, fmt};
99

1010
#[cfg(feature = "arbitrary")]
1111
use arbitrary::{Arbitrary, Unstructured};
12-
1312
use internals::write_err;
1413

1514
use crate::Sequence;
@@ -525,7 +524,7 @@ impl<'a> Arbitrary<'a> for LockTime {
525524
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
526525
match bool::arbitrary(u)? {
527526
true => Ok(LockTime::Blocks(NumberOfBlocks::arbitrary(u)?)),
528-
false => Ok(LockTime::Time(NumberOf512Seconds::arbitrary(u)?))
527+
false => Ok(LockTime::Time(NumberOf512Seconds::arbitrary(u)?)),
529528
}
530529
}
531530
}

units/src/amount/serde.rs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ pub mod as_sat {
7474

7575
pub fn deserialize<'d, A, D: Deserializer<'d>>(d: D) -> Result<A, D::Error>
7676
where
77-
A: TryFrom<SignedAmount>, <A as TryFrom<SignedAmount>>::Error: core::fmt::Display
77+
A: TryFrom<SignedAmount>,
78+
<A as TryFrom<SignedAmount>>::Error: core::fmt::Display,
7879
{
7980
let sat = i64::deserialize(d)?;
80-
let amount = SignedAmount::from_sat(sat)
81-
.map_err(serde::de::Error::custom)?;
81+
let amount = SignedAmount::from_sat(sat).map_err(serde::de::Error::custom)?;
8282

8383
A::try_from(amount).map_err(serde::de::Error::custom)
8484
}
@@ -112,13 +112,15 @@ pub mod as_sat {
112112

113113
pub fn deserialize<'d, A, D: Deserializer<'d>>(d: D) -> Result<Option<A>, D::Error>
114114
where
115-
A: TryFrom<SignedAmount>, <A as TryFrom<SignedAmount>>::Error: core::fmt::Display
115+
A: TryFrom<SignedAmount>,
116+
<A as TryFrom<SignedAmount>>::Error: core::fmt::Display,
116117
{
117118
struct VisitOptAmt<X>(PhantomData<X>);
118119

119120
impl<'de, X> de::Visitor<'de> for VisitOptAmt<X>
120121
where
121-
X: TryFrom<SignedAmount>, <X as TryFrom<SignedAmount>>::Error: core::fmt::Display
122+
X: TryFrom<SignedAmount>,
123+
<X as TryFrom<SignedAmount>>::Error: core::fmt::Display,
122124
{
123125
type Value = Option<X>;
124126

@@ -169,7 +171,8 @@ pub mod as_btc {
169171

170172
pub fn deserialize<'d, A, D: Deserializer<'d>>(d: D) -> Result<A, D::Error>
171173
where
172-
A: TryFrom<SignedAmount>, <A as TryFrom<SignedAmount>>::Error: core::fmt::Display
174+
A: TryFrom<SignedAmount>,
175+
<A as TryFrom<SignedAmount>>::Error: core::fmt::Display,
173176
{
174177
let btc = f64::deserialize(d)?;
175178
let amount = SignedAmount::from_btc(btc)
@@ -208,13 +211,15 @@ pub mod as_btc {
208211

209212
pub fn deserialize<'d, A, D: Deserializer<'d>>(d: D) -> Result<Option<A>, D::Error>
210213
where
211-
A: TryFrom<SignedAmount>, <A as TryFrom<SignedAmount>>::Error: core::fmt::Display
214+
A: TryFrom<SignedAmount>,
215+
<A as TryFrom<SignedAmount>>::Error: core::fmt::Display,
212216
{
213217
struct VisitOptAmt<X>(PhantomData<X>);
214218

215219
impl<'de, X> de::Visitor<'de> for VisitOptAmt<X>
216220
where
217-
X: TryFrom<SignedAmount>, <X as TryFrom<SignedAmount>>::Error: core::fmt::Display
221+
X: TryFrom<SignedAmount>,
222+
<X as TryFrom<SignedAmount>>::Error: core::fmt::Display,
218223
{
219224
type Value = Option<X>;
220225

@@ -251,6 +256,7 @@ pub mod as_str {
251256
//! [`SignedAmount`]: crate::SignedAmount
252257
253258
use alloc::string::String;
259+
254260
use serde::{Deserialize, Deserializer, Serialize, Serializer};
255261

256262
use super::DisplayFullError;
@@ -266,7 +272,8 @@ pub mod as_str {
266272

267273
pub fn deserialize<'d, A, D: Deserializer<'d>>(d: D) -> Result<A, D::Error>
268274
where
269-
A: TryFrom<SignedAmount>, <A as TryFrom<SignedAmount>>::Error: core::fmt::Display
275+
A: TryFrom<SignedAmount>,
276+
<A as TryFrom<SignedAmount>>::Error: core::fmt::Display,
270277
{
271278
let btc = String::deserialize(d)?;
272279
let amount = SignedAmount::from_str_in(&btc, Denomination::Bitcoin)
@@ -290,10 +297,7 @@ pub mod as_str {
290297
use crate::amount::{Denomination, SignedAmount};
291298

292299
#[allow(clippy::ref_option)] // API forced by serde.
293-
pub fn serialize<A, S: Serializer>(
294-
a: &Option<A>,
295-
s: S,
296-
) -> Result<S::Ok, S::Error>
300+
pub fn serialize<A, S: Serializer>(a: &Option<A>, s: S) -> Result<S::Ok, S::Error>
297301
where
298302
A: Into<SignedAmount> + Copy,
299303
{
@@ -306,17 +310,17 @@ pub mod as_str {
306310
}
307311
}
308312

309-
pub fn deserialize<'d, A, D: Deserializer<'d>>(
310-
d: D,
311-
) -> Result<Option<A>, D::Error>
313+
pub fn deserialize<'d, A, D: Deserializer<'d>>(d: D) -> Result<Option<A>, D::Error>
312314
where
313-
A: TryFrom<SignedAmount>, <A as TryFrom<SignedAmount>>::Error: core::fmt::Display
315+
A: TryFrom<SignedAmount>,
316+
<A as TryFrom<SignedAmount>>::Error: core::fmt::Display,
314317
{
315318
struct VisitOptAmt<X>(PhantomData<X>);
316319

317320
impl<'de, X> de::Visitor<'de> for VisitOptAmt<X>
318321
where
319-
X: TryFrom<SignedAmount>, <X as TryFrom<SignedAmount>>::Error: core::fmt::Display
322+
X: TryFrom<SignedAmount>,
323+
<X as TryFrom<SignedAmount>>::Error: core::fmt::Display,
320324
{
321325
type Value = Option<X>;
322326

@@ -346,7 +350,7 @@ pub mod as_str {
346350
#[cfg(test)]
347351
mod tests {
348352

349-
use serde::{Serialize, Deserialize};
353+
use serde::{Deserialize, Serialize};
350354

351355
use crate::amount::{self, Amount, SignedAmount};
352356

units/src/amount/tests.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -847,19 +847,11 @@ fn sum_amounts() {
847847
assert_eq!(empty.into_iter().sum::<NumOpResult<_>>(), NumOpResult::Valid(SignedAmount::ZERO));
848848

849849
let amounts = [sat(42), sat(1337), sat(21)];
850-
let sum = amounts
851-
.into_iter()
852-
.map(NumOpResult::from)
853-
.sum::<NumOpResult<Amount>>()
854-
.unwrap();
850+
let sum = amounts.into_iter().map(NumOpResult::from).sum::<NumOpResult<Amount>>().unwrap();
855851
assert_eq!(sum, sat(1400));
856852

857853
let amounts = [Amount::MAX_MONEY, sat(1337), sat(21)];
858-
assert!(amounts
859-
.into_iter()
860-
.map(NumOpResult::from)
861-
.sum::<NumOpResult<Amount>>()
862-
.is_error());
854+
assert!(amounts.into_iter().map(NumOpResult::from).sum::<NumOpResult<Amount>>().is_error());
863855

864856
let amounts = [SignedAmount::MIN, ssat(-1), ssat(21)];
865857
assert!(amounts
@@ -876,11 +868,8 @@ fn sum_amounts() {
876868
.is_error());
877869

878870
let amounts = [ssat(42), ssat(3301), ssat(21)];
879-
let sum = amounts
880-
.into_iter()
881-
.map(NumOpResult::from)
882-
.sum::<NumOpResult<SignedAmount>>()
883-
.unwrap();
871+
let sum =
872+
amounts.into_iter().map(NumOpResult::from).sum::<NumOpResult<SignedAmount>>().unwrap();
884873
assert_eq!(sum, ssat(3364));
885874
}
886875

0 commit comments

Comments
 (0)