Skip to content

Commit 6fe7b20

Browse files
committed
Set fn_single_line to true
Set `rustfmt` config option `fn_single_line` to true and run the formatter.
1 parent 780dbc6 commit 6fe7b20

33 files changed

+249
-745
lines changed

bitcoind-tests/tests/test_cpp.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ where
4444
}
4545

4646
/// Quickly create a BTC amount.
47-
fn btc<F: Into<f64>>(btc: F) -> Amount {
48-
Amount::from_btc(btc.into()).unwrap()
49-
}
47+
fn btc<F: Into<f64>>(btc: F) -> Amount { Amount::from_btc(btc.into()).unwrap() }
5048

5149
// Find the Outpoint by value.
5250
// Ideally, we should find by scriptPubkey, but this
@@ -247,9 +245,7 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
247245
}
248246

249247
#[test]
250-
fn test_setup() {
251-
setup::setup();
252-
}
248+
fn test_setup() { setup::setup(); }
253249

254250
#[test]
255251
fn tests_from_cpp() {

bitcoind-tests/tests/test_desc.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ mod setup;
2525
use rand::RngCore;
2626
use setup::test_util::{self, TestData};
2727
/// Quickly create a BTC amount.
28-
fn btc<F: Into<f64>>(btc: F) -> Amount {
29-
Amount::from_btc(btc.into()).unwrap()
30-
}
28+
fn btc<F: Into<f64>>(btc: F) -> Amount { Amount::from_btc(btc.into()).unwrap() }
3129

3230
// Find the Outpoint by spk
3331
fn get_vout(cl: &Client, txid: Txid, value: u64, spk: ScriptBuf) -> (OutPoint, TxOut) {

rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ format_macro_bodies = true
2222
hex_literal_case = "Preserve"
2323
empty_item_single_line = true
2424
struct_lit_single_line = true
25-
fn_single_line = false
25+
fn_single_line = true
2626
where_single_line = false
2727
imports_indent = "Block"
2828
imports_layout = "Mixed"

src/descriptor/bare.rs

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,10 @@ impl<Pk: MiniscriptKey> Bare<Pk> {
4343
}
4444

4545
/// get the inner
46-
pub fn into_inner(self) -> Miniscript<Pk, BareCtx> {
47-
self.ms
48-
}
46+
pub fn into_inner(self) -> Miniscript<Pk, BareCtx> { self.ms }
4947

5048
/// get the inner
51-
pub fn as_inner(&self) -> &Miniscript<Pk, BareCtx> {
52-
&self.ms
53-
}
49+
pub fn as_inner(&self) -> &Miniscript<Pk, BareCtx> { &self.ms }
5450

5551
/// Checks whether the descriptor is safe.
5652
pub fn sanity_check(&self) -> Result<(), Error> {
@@ -96,19 +92,13 @@ impl<Pk: MiniscriptKey> Bare<Pk> {
9692

9793
impl<Pk: MiniscriptKey + ToPublicKey> Bare<Pk> {
9894
/// Obtains the corresponding script pubkey for this descriptor.
99-
pub fn script_pubkey(&self) -> ScriptBuf {
100-
self.ms.encode()
101-
}
95+
pub fn script_pubkey(&self) -> ScriptBuf { self.ms.encode() }
10296

10397
/// Obtains the underlying miniscript for this descriptor.
104-
pub fn inner_script(&self) -> ScriptBuf {
105-
self.script_pubkey()
106-
}
98+
pub fn inner_script(&self) -> ScriptBuf { self.script_pubkey() }
10799

108100
/// Obtains the pre bip-340 signature script code for this descriptor.
109-
pub fn ecdsa_sighash_script_code(&self) -> ScriptBuf {
110-
self.script_pubkey()
111-
}
101+
pub fn ecdsa_sighash_script_code(&self) -> ScriptBuf { self.script_pubkey() }
112102

113103
/// Returns satisfying non-malleable witness and scriptSig with minimum
114104
/// weight to spend an output controlled by the given descriptor if it is
@@ -162,9 +152,7 @@ impl Bare<DefiniteDescriptorKey> {
162152
}
163153

164154
impl<Pk: MiniscriptKey> fmt::Debug for Bare<Pk> {
165-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
166-
write!(f, "{:?}", self.ms)
167-
}
155+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}", self.ms) }
168156
}
169157

170158
impl<Pk: MiniscriptKey> fmt::Display for Bare<Pk> {
@@ -177,9 +165,7 @@ impl<Pk: MiniscriptKey> fmt::Display for Bare<Pk> {
177165
}
178166

179167
impl<Pk: MiniscriptKey> Liftable<Pk> for Bare<Pk> {
180-
fn lift(&self) -> Result<semantic::Policy<Pk>, Error> {
181-
self.ms.lift()
182-
}
168+
fn lift(&self) -> Result<semantic::Policy<Pk>, Error> { self.ms.lift() }
183169
}
184170

185171
impl_from_tree!(
@@ -240,14 +226,10 @@ impl<Pk: MiniscriptKey> Pkh<Pk> {
240226
}
241227

242228
/// Get a reference to the inner key
243-
pub fn as_inner(&self) -> &Pk {
244-
&self.pk
245-
}
229+
pub fn as_inner(&self) -> &Pk { &self.pk }
246230

247231
/// Get the inner key
248-
pub fn into_inner(self) -> Pk {
249-
self.pk
250-
}
232+
pub fn into_inner(self) -> Pk { self.pk }
251233

252234
/// Computes an upper bound on the difference between a non-satisfied
253235
/// `TxIn`'s `segwit_weight` and a satisfied `TxIn`'s `segwit_weight`
@@ -276,9 +258,7 @@ impl<Pk: MiniscriptKey> Pkh<Pk> {
276258
/// Assumes all ec-signatures are 73 bytes, including push opcode and
277259
/// sighash suffix. Includes the weight of the VarInts encoding the
278260
/// scriptSig and witness stack length.
279-
pub fn max_satisfaction_weight(&self) -> usize {
280-
4 * (1 + 73 + BareCtx::pk_len(&self.pk))
281-
}
261+
pub fn max_satisfaction_weight(&self) -> usize { 4 * (1 + 73 + BareCtx::pk_len(&self.pk)) }
282262
}
283263

284264
impl<Pk: MiniscriptKey + ToPublicKey> Pkh<Pk> {
@@ -296,14 +276,10 @@ impl<Pk: MiniscriptKey + ToPublicKey> Pkh<Pk> {
296276
}
297277

298278
/// Obtains the underlying miniscript for this descriptor.
299-
pub fn inner_script(&self) -> ScriptBuf {
300-
self.script_pubkey()
301-
}
279+
pub fn inner_script(&self) -> ScriptBuf { self.script_pubkey() }
302280

303281
/// Obtains the pre bip-340 signature script code for this descriptor.
304-
pub fn ecdsa_sighash_script_code(&self) -> ScriptBuf {
305-
self.script_pubkey()
306-
}
282+
pub fn ecdsa_sighash_script_code(&self) -> ScriptBuf { self.script_pubkey() }
307283

308284
/// Returns satisfying non-malleable witness and scriptSig with minimum
309285
/// weight to spend an output controlled by the given descriptor if it is
@@ -378,9 +354,7 @@ impl Pkh<DefiniteDescriptorKey> {
378354
}
379355

380356
impl<Pk: MiniscriptKey> fmt::Debug for Pkh<Pk> {
381-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
382-
write!(f, "pkh({:?})", self.pk)
383-
}
357+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "pkh({:?})", self.pk) }
384358
}
385359

386360
impl<Pk: MiniscriptKey> fmt::Display for Pkh<Pk> {
@@ -426,9 +400,7 @@ impl_from_str!(
426400
);
427401

428402
impl<Pk: MiniscriptKey> ForEachKey<Pk> for Pkh<Pk> {
429-
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool {
430-
pred(&self.pk)
431-
}
403+
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool { pred(&self.pk) }
432404
}
433405

434406
impl<P, Q> TranslatePk<P, Q> for Pkh<P>

src/descriptor/checksum.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ pub struct Engine {
8080
}
8181

8282
impl Default for Engine {
83-
fn default() -> Engine {
84-
Engine::new()
85-
}
83+
fn default() -> Engine { Engine::new() }
8684
}
8785

8886
impl Engine {

src/descriptor/key.rs

Lines changed: 20 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,10 @@ impl DerivPaths {
8686
}
8787

8888
/// Get the list of derivation paths.
89-
pub fn paths(&self) -> &Vec<bip32::DerivationPath> {
90-
&self.0
91-
}
89+
pub fn paths(&self) -> &Vec<bip32::DerivationPath> { &self.0 }
9290

9391
/// Get the list of derivation paths.
94-
pub fn into_paths(self) -> Vec<bip32::DerivationPath> {
95-
self.0
96-
}
92+
pub fn into_paths(self) -> Vec<bip32::DerivationPath> { self.0 }
9793
}
9894

9995
/// Instance of one or more extended keys, as specified in BIP 389.
@@ -173,19 +169,15 @@ impl InnerXKey for bip32::ExtendedPubKey {
173169
self.fingerprint()
174170
}
175171

176-
fn can_derive_hardened() -> bool {
177-
false
178-
}
172+
fn can_derive_hardened() -> bool { false }
179173
}
180174

181175
impl InnerXKey for bip32::ExtendedPrivKey {
182176
fn xkey_fingerprint<C: Signing>(&self, secp: &Secp256k1<C>) -> bip32::Fingerprint {
183177
self.fingerprint(secp)
184178
}
185179

186-
fn can_derive_hardened() -> bool {
187-
true
188-
}
180+
fn can_derive_hardened() -> bool { true }
189181
}
190182

191183
/// Whether a descriptor has a wildcard in it
@@ -271,16 +263,12 @@ impl DescriptorXKey<bip32::ExtendedPrivKey> {
271263
pub struct DescriptorKeyParseError(&'static str);
272264

273265
impl fmt::Display for DescriptorKeyParseError {
274-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
275-
f.write_str(self.0)
276-
}
266+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(self.0) }
277267
}
278268

279269
#[cfg(feature = "std")]
280270
impl error::Error for DescriptorKeyParseError {
281-
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
282-
None
283-
}
271+
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
284272
}
285273

286274
impl fmt::Display for DescriptorPublicKey {
@@ -621,9 +609,7 @@ impl DescriptorPublicKey {
621609

622610
/// Whether or not the key has a wildcard
623611
#[deprecated(note = "use has_wildcard instead")]
624-
pub fn is_deriveable(&self) -> bool {
625-
self.has_wildcard()
626-
}
612+
pub fn is_deriveable(&self) -> bool { self.has_wildcard() }
627613

628614
/// Whether or not the key has a wildcard
629615
pub fn has_wildcard(&self) -> bool {
@@ -1093,9 +1079,7 @@ impl DefiniteDescriptorKey {
10931079
}
10941080

10951081
/// The fingerprint of the master key associated with this key, `0x00000000` if none.
1096-
pub fn master_fingerprint(&self) -> bip32::Fingerprint {
1097-
self.0.master_fingerprint()
1098-
}
1082+
pub fn master_fingerprint(&self) -> bip32::Fingerprint { self.0.master_fingerprint() }
10991083

11001084
/// Full path from the master key if not a multipath extended key.
11011085
pub fn full_derivation_path(&self) -> Option<bip32::DerivationPath> {
@@ -1109,14 +1093,10 @@ impl DefiniteDescriptorKey {
11091093
}
11101094

11111095
/// Reference to the underlying `DescriptorPublicKey`
1112-
pub fn as_descriptor_public_key(&self) -> &DescriptorPublicKey {
1113-
&self.0
1114-
}
1096+
pub fn as_descriptor_public_key(&self) -> &DescriptorPublicKey { &self.0 }
11151097

11161098
/// Converts the definite key into a generic one
1117-
pub fn into_descriptor_public_key(self) -> DescriptorPublicKey {
1118-
self.0
1119-
}
1099+
pub fn into_descriptor_public_key(self) -> DescriptorPublicKey { self.0 }
11201100
}
11211101

11221102
impl FromStr for DefiniteDescriptorKey {
@@ -1131,9 +1111,7 @@ impl FromStr for DefiniteDescriptorKey {
11311111
}
11321112

11331113
impl fmt::Display for DefiniteDescriptorKey {
1134-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1135-
self.0.fmt(f)
1136-
}
1114+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.0.fmt(f) }
11371115
}
11381116

11391117
impl MiniscriptKey for DefiniteDescriptorKey {
@@ -1142,17 +1120,11 @@ impl MiniscriptKey for DefiniteDescriptorKey {
11421120
type Ripemd160 = ripemd160::Hash;
11431121
type Hash160 = hash160::Hash;
11441122

1145-
fn is_uncompressed(&self) -> bool {
1146-
self.0.is_uncompressed()
1147-
}
1123+
fn is_uncompressed(&self) -> bool { self.0.is_uncompressed() }
11481124

1149-
fn is_x_only_key(&self) -> bool {
1150-
self.0.is_x_only_key()
1151-
}
1125+
fn is_x_only_key(&self) -> bool { self.0.is_x_only_key() }
11521126

1153-
fn num_der_paths(&self) -> usize {
1154-
self.0.num_der_paths()
1155-
}
1127+
fn num_der_paths(&self) -> usize { self.0.num_der_paths() }
11561128
}
11571129

11581130
impl ToPublicKey for DefiniteDescriptorKey {
@@ -1161,33 +1133,21 @@ impl ToPublicKey for DefiniteDescriptorKey {
11611133
self.derive_public_key(&secp).unwrap()
11621134
}
11631135

1164-
fn to_sha256(hash: &sha256::Hash) -> sha256::Hash {
1165-
*hash
1166-
}
1136+
fn to_sha256(hash: &sha256::Hash) -> sha256::Hash { *hash }
11671137

1168-
fn to_hash256(hash: &hash256::Hash) -> hash256::Hash {
1169-
*hash
1170-
}
1138+
fn to_hash256(hash: &hash256::Hash) -> hash256::Hash { *hash }
11711139

1172-
fn to_ripemd160(hash: &ripemd160::Hash) -> ripemd160::Hash {
1173-
*hash
1174-
}
1140+
fn to_ripemd160(hash: &ripemd160::Hash) -> ripemd160::Hash { *hash }
11751141

1176-
fn to_hash160(hash: &hash160::Hash) -> hash160::Hash {
1177-
*hash
1178-
}
1142+
fn to_hash160(hash: &hash160::Hash) -> hash160::Hash { *hash }
11791143
}
11801144

11811145
impl From<DefiniteDescriptorKey> for DescriptorPublicKey {
1182-
fn from(d: DefiniteDescriptorKey) -> Self {
1183-
d.0
1184-
}
1146+
fn from(d: DefiniteDescriptorKey) -> Self { d.0 }
11851147
}
11861148

11871149
impl Borrow<DescriptorPublicKey> for DefiniteDescriptorKey {
1188-
fn borrow(&self) -> &DescriptorPublicKey {
1189-
&self.0
1190-
}
1150+
fn borrow(&self) -> &DescriptorPublicKey { &self.0 }
11911151
}
11921152

11931153
#[cfg(feature = "serde")]

0 commit comments

Comments
 (0)