From 1629348c24e83310bd7760d58a318208197c1a31 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Thu, 17 Mar 2022 07:22:03 +1100 Subject: [PATCH] Use conventional spacing for default type parameters The exact code formatting we use is not as important as uniformity. Since we do not use tooling to control the formatting we have to be vigilant ourselves. Recently I (Tobin) changed the way default type parameters were formatted (arbitrarily but uniformly). Turns out I picked the wrong way, there is already a convention as shown in the rust documentation online (e.g. [1]). Use 'conventional' spacing for default type parameters. Make the change across the whole repository, found using git grep '\<.* = .*\>' [1] - https://doc.rust-lang.org/book/ch19-03-advanced-traits.html --- src/util/amount.rs | 8 ++++---- src/util/base58.rs | 4 ++-- src/util/bip32.rs | 2 +- src/util/hash.rs | 2 +- src/util/psbt/raw.rs | 2 +- src/util/sighash.rs | 6 +++--- src/util/taproot.rs | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/util/amount.rs b/src/util/amount.rs index 681a804c..c9cca684 100644 --- a/src/util/amount.rs +++ b/src/util/amount.rs @@ -946,7 +946,7 @@ pub trait CheckedSum: private::SumSeal { fn checked_sum(self) -> Option; } -impl CheckedSum for T where T: Iterator { +impl CheckedSum for T where T: Iterator { fn checked_sum(mut self) -> Option { let first = Some(self.next().unwrap_or_default()); @@ -957,7 +957,7 @@ impl CheckedSum for T where T: Iterator { } } -impl CheckedSum for T where T: Iterator { +impl CheckedSum for T where T: Iterator { fn checked_sum(mut self) -> Option { let first = Some(self.next().unwrap_or_default()); @@ -971,8 +971,8 @@ mod private { /// Used to seal the `CheckedSum` trait pub trait SumSeal {} - impl SumSeal for T where T: Iterator {} - impl SumSeal for T where T: Iterator {} + impl SumSeal for T where T: Iterator {} + impl SumSeal for T where T: Iterator {} } #[cfg(feature = "serde")] diff --git a/src/util/base58.rs b/src/util/base58.rs index 7ad941b8..6bbdc9ad 100644 --- a/src/util/base58.rs +++ b/src/util/base58.rs @@ -178,7 +178,7 @@ pub fn from_check(data: &str) -> Result, Error> { fn format_iter(writer: &mut W, data: I) -> Result<(), fmt::Error> where - I: Iterator + Clone, + I: Iterator + Clone, W: fmt::Write { let mut ret = SmallVec::new(); @@ -219,7 +219,7 @@ where fn encode_iter(data: I) -> String where - I: Iterator + Clone, + I: Iterator + Clone, { let mut ret = String::new(); format_iter(&mut ret, data).expect("writing into string shouldn't fail"); diff --git a/src/util/bip32.rs b/src/util/bip32.rs index 443fed81..2876c97e 100644 --- a/src/util/bip32.rs +++ b/src/util/bip32.rs @@ -284,7 +284,7 @@ impl<'a> From<&'a [ChildNumber]> for DerivationPath { } impl ::core::iter::FromIterator for DerivationPath { - fn from_iter(iter: T) -> Self where T: IntoIterator { + fn from_iter(iter: T) -> Self where T: IntoIterator { DerivationPath(Vec::from_iter(iter)) } } diff --git a/src/util/hash.rs b/src/util/hash.rs index 5d9f540d..6a14d07b 100644 --- a/src/util/hash.rs +++ b/src/util/hash.rs @@ -57,7 +57,7 @@ pub fn bitcoin_merkle_root(mut hashes: I) -> Option where T: Hash + Encodable, ::Engine: io::Write, - I: Iterator, + I: Iterator, { let first = hashes.next()?; let second = match hashes.next() { diff --git a/src/util/psbt/raw.rs b/src/util/psbt/raw.rs index 3a99e2ab..7e028570 100644 --- a/src/util/psbt/raw.rs +++ b/src/util/psbt/raw.rs @@ -56,7 +56,7 @@ pub type ProprietaryType = u8; /// structure according to BIP 174. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct ProprietaryKey where Subtype: Copy + From + Into { +pub struct ProprietaryKey where Subtype: Copy + From + Into { /// Proprietary type prefix used for grouping together keys under some /// application and avoid namespace collision #[cfg_attr(feature = "serde", serde(with = "::serde_utils::hex_bytes"))] diff --git a/src/util/sighash.rs b/src/util/sighash.rs index ad248fd7..43a70a37 100644 --- a/src/util/sighash.rs +++ b/src/util/sighash.rs @@ -36,7 +36,7 @@ use super::taproot::LeafVersion; /// Efficiently calculates signature hash message for legacy, segwit and taproot inputs. #[derive(Debug)] -pub struct SigHashCache> { +pub struct SigHashCache> { /// Access to transaction required for various introspection, moreover type /// `T: Deref` allows to accept borrow and mutable borrow, the /// latter in particular is necessary for [`SigHashCache::witness_mut`] @@ -295,7 +295,7 @@ impl SchnorrSigHashType { } } -impl> SigHashCache { +impl> SigHashCache { /// Compute the sighash components from an unsigned transaction and auxiliary /// in a lazy manner when required. /// For the generated sighashes to be valid, no fields in the transaction may change except for @@ -692,7 +692,7 @@ impl> SigHashCache { } } -impl> SigHashCache { +impl> SigHashCache { /// When the SigHashCache is initialized with a mutable reference to a transaction instead of a /// regular reference, this method is available to allow modification to the witnesses. /// diff --git a/src/util/taproot.rs b/src/util/taproot.rs index d189ddcf..cb9950db 100644 --- a/src/util/taproot.rs +++ b/src/util/taproot.rs @@ -215,7 +215,7 @@ impl TaprootSpendInfo { script_weights: I, ) -> Result where - I: IntoIterator, + I: IntoIterator, C: secp256k1::Verification, { let mut node_weights = BinaryHeap::<(Reverse, NodeInfo)>::new();