Merge rust-bitcoin/rust-bitcoin#880: Use conventional spacing for default type parameters

1629348c24 Use conventional spacing for default type parameters (Tobin Harding)

Pull request description:

  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 changeacross the whole repository, found using

      git grep '\<.* = .*\>'

  [1] - https://doc.rust-lang.org/book/ch19-03-advanced-traits.html

  **Note**

  I also audited our whole stack to make sure I had not botched this anywhere else. Apologies for the code churn.

ACKs for top commit:
  dr-orlovsky:
    utACK 1629348c24
  apoelstra:
    ACK 1629348c24

Tree-SHA512: 61c8a22acc557d8b99f7b591cf8f91b94778a954ac1c9d6cf04a2bbd10953c241e8298e71928aad3b065c98117b816b913226d973fdaa9c3a1aea8daf8bcbe72
This commit is contained in:
Andrew Poelstra 2022-03-21 21:09:25 +00:00
commit 1cde71ea44
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
7 changed files with 13 additions and 13 deletions

View File

@ -946,7 +946,7 @@ pub trait CheckedSum<R>: private::SumSeal<R> {
fn checked_sum(self) -> Option<R>;
}
impl<T> CheckedSum<Amount> for T where T: Iterator<Item = Amount> {
impl<T> CheckedSum<Amount> for T where T: Iterator<Item=Amount> {
fn checked_sum(mut self) -> Option<Amount> {
let first = Some(self.next().unwrap_or_default());
@ -957,7 +957,7 @@ impl<T> CheckedSum<Amount> for T where T: Iterator<Item = Amount> {
}
}
impl<T> CheckedSum<SignedAmount> for T where T: Iterator<Item = SignedAmount> {
impl<T> CheckedSum<SignedAmount> for T where T: Iterator<Item=SignedAmount> {
fn checked_sum(mut self) -> Option<SignedAmount> {
let first = Some(self.next().unwrap_or_default());
@ -971,8 +971,8 @@ mod private {
/// Used to seal the `CheckedSum` trait
pub trait SumSeal<A> {}
impl<T> SumSeal<Amount> for T where T: Iterator<Item = Amount> {}
impl<T> SumSeal<SignedAmount> for T where T: Iterator<Item = SignedAmount> {}
impl<T> SumSeal<Amount> for T where T: Iterator<Item=Amount> {}
impl<T> SumSeal<SignedAmount> for T where T: Iterator<Item=SignedAmount> {}
}
#[cfg(feature = "serde")]

View File

@ -178,7 +178,7 @@ pub fn from_check(data: &str) -> Result<Vec<u8>, Error> {
fn format_iter<I, W>(writer: &mut W, data: I) -> Result<(), fmt::Error>
where
I: Iterator<Item = u8> + Clone,
I: Iterator<Item=u8> + Clone,
W: fmt::Write
{
let mut ret = SmallVec::new();
@ -219,7 +219,7 @@ where
fn encode_iter<I>(data: I) -> String
where
I: Iterator<Item = u8> + Clone,
I: Iterator<Item=u8> + Clone,
{
let mut ret = String::new();
format_iter(&mut ret, data).expect("writing into string shouldn't fail");

View File

@ -284,7 +284,7 @@ impl<'a> From<&'a [ChildNumber]> for DerivationPath {
}
impl ::core::iter::FromIterator<ChildNumber> for DerivationPath {
fn from_iter<T>(iter: T) -> Self where T: IntoIterator<Item = ChildNumber> {
fn from_iter<T>(iter: T) -> Self where T: IntoIterator<Item=ChildNumber> {
DerivationPath(Vec::from_iter(iter))
}
}

View File

@ -57,7 +57,7 @@ pub fn bitcoin_merkle_root<T, I>(mut hashes: I) -> Option<T>
where
T: Hash + Encodable,
<T as Hash>::Engine: io::Write,
I: Iterator<Item = T>,
I: Iterator<Item=T>,
{
let first = hashes.next()?;
let second = match hashes.next() {

View File

@ -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<Subtype = ProprietaryType> where Subtype: Copy + From<u8> + Into<u8> {
pub struct ProprietaryKey<Subtype=ProprietaryType> where Subtype: Copy + From<u8> + Into<u8> {
/// 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"))]

View File

@ -36,7 +36,7 @@ use super::taproot::LeafVersion;
/// Efficiently calculates signature hash message for legacy, segwit and taproot inputs.
#[derive(Debug)]
pub struct SigHashCache<T: Deref<Target = Transaction>> {
pub struct SigHashCache<T: Deref<Target=Transaction>> {
/// Access to transaction required for various introspection, moreover type
/// `T: Deref<Target=Transaction>` allows to accept borrow and mutable borrow, the
/// latter in particular is necessary for [`SigHashCache::witness_mut`]
@ -295,7 +295,7 @@ impl SchnorrSigHashType {
}
}
impl<R: Deref<Target = Transaction>> SigHashCache<R> {
impl<R: Deref<Target=Transaction>> SigHashCache<R> {
/// 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<R: Deref<Target = Transaction>> SigHashCache<R> {
}
}
impl<R: DerefMut<Target = Transaction>> SigHashCache<R> {
impl<R: DerefMut<Target=Transaction>> SigHashCache<R> {
/// 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.
///

View File

@ -215,7 +215,7 @@ impl TaprootSpendInfo {
script_weights: I,
) -> Result<Self, TaprootBuilderError>
where
I: IntoIterator<Item = (u32, Script)>,
I: IntoIterator<Item=(u32, Script)>,
C: secp256k1::Verification,
{
let mut node_weights = BinaryHeap::<(Reverse<u64>, NodeInfo)>::new();