From 5f2395ce5635d93ca27a445df58188b21e2bceda Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 5 Nov 2023 04:33:44 +0000 Subject: [PATCH] Add missing `?Sized` bounds to `io::Write` parameters Since we are no longer relying on the blanket `io::Write` impl for `&mut io::Write`, we should now ensure that we do not require `Sized` for our `io::Write` bounds, as its unnecessarily restrictive and can no longer be worked around by simply adding an `&mut`. --- bitcoin/src/crypto/key.rs | 2 +- bitcoin/src/crypto/sighash.rs | 8 ++++---- bitcoin/src/taproot.rs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs index 366369a4..7ba63a89 100644 --- a/bitcoin/src/crypto/key.rs +++ b/bitcoin/src/crypto/key.rs @@ -68,7 +68,7 @@ impl PublicKey { } /// Write the public key into a writer - pub fn write_into(&self, writer: &mut W) -> Result<(), io::Error> { + pub fn write_into(&self, writer: &mut W) -> Result<(), io::Error> { self.with_serialized(|bytes| writer.write_all(bytes)) } diff --git a/bitcoin/src/crypto/sighash.rs b/bitcoin/src/crypto/sighash.rs index 859aa34d..6fb2ddbe 100644 --- a/bitcoin/src/crypto/sighash.rs +++ b/bitcoin/src/crypto/sighash.rs @@ -673,7 +673,7 @@ impl> SighashCache { /// Encodes the BIP341 signing data for any flag type into a given object implementing a /// [`io::Write`] trait. - pub fn taproot_encode_signing_data_to>( + pub fn taproot_encode_signing_data_to>( &mut self, writer: &mut Write, input_index: usize, @@ -860,7 +860,7 @@ impl> SighashCache { /// `script_code` is dependent on the type of the spend transaction. For p2wpkh use /// [`Script::p2wpkh_script_code`], for p2wsh just pass in the witness script. (Also see /// [`Self::p2wpkh_signature_hash`] and [`SighashCache::p2wsh_signature_hash`].) - pub fn segwit_v0_encode_signing_data_to( + pub fn segwit_v0_encode_signing_data_to( &mut self, writer: &mut Write, input_index: usize, @@ -984,7 +984,7 @@ impl> SighashCache { /// /// This function can't handle the SIGHASH_SINGLE bug internally, so it returns [`EncodeSigningDataResult`] /// that must be handled by the caller (see [`EncodeSigningDataResult::is_sighash_single_bug`]). - pub fn legacy_encode_signing_data_to>( + pub fn legacy_encode_signing_data_to>( &self, writer: &mut Write, input_index: usize, @@ -1011,7 +1011,7 @@ impl> SighashCache { return EncodeSigningDataResult::SighashSingleBug; } - fn encode_signing_data_to_inner( + fn encode_signing_data_to_inner( self_: &Transaction, writer: &mut Write, input_index: usize, diff --git a/bitcoin/src/taproot.rs b/bitcoin/src/taproot.rs index addf3de0..c6bd03c5 100644 --- a/bitcoin/src/taproot.rs +++ b/bitcoin/src/taproot.rs @@ -1109,7 +1109,7 @@ impl TaprootMerkleBranch { /// # Returns /// /// The number of bytes written to the writer. - pub fn encode(&self, writer: &mut Write) -> io::Result { + pub fn encode(&self, writer: &mut Write) -> io::Result { for hash in self.0.iter() { writer.write_all(hash.as_ref())?; } @@ -1237,7 +1237,7 @@ impl ControlBlock { /// # Returns /// /// The number of bytes written to the writer. - pub fn encode(&self, writer: &mut Write) -> io::Result { + pub fn encode(&self, writer: &mut Write) -> io::Result { let first_byte: u8 = i32::from(self.output_key_parity) as u8 | self.leaf_version.to_consensus(); writer.write_all(&[first_byte])?;