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`.
This commit is contained in:
Matt Corallo 2023-11-05 04:33:44 +00:00
parent 2348449d2a
commit 5f2395ce56
3 changed files with 7 additions and 7 deletions

View File

@ -68,7 +68,7 @@ impl PublicKey {
} }
/// Write the public key into a writer /// Write the public key into a writer
pub fn write_into<W: io::Write>(&self, writer: &mut W) -> Result<(), io::Error> { pub fn write_into<W: io::Write + ?Sized>(&self, writer: &mut W) -> Result<(), io::Error> {
self.with_serialized(|bytes| writer.write_all(bytes)) self.with_serialized(|bytes| writer.write_all(bytes))
} }

View File

@ -673,7 +673,7 @@ impl<R: Borrow<Transaction>> SighashCache<R> {
/// Encodes the BIP341 signing data for any flag type into a given object implementing a /// Encodes the BIP341 signing data for any flag type into a given object implementing a
/// [`io::Write`] trait. /// [`io::Write`] trait.
pub fn taproot_encode_signing_data_to<Write: io::Write, T: Borrow<TxOut>>( pub fn taproot_encode_signing_data_to<Write: io::Write + ?Sized, T: Borrow<TxOut>>(
&mut self, &mut self,
writer: &mut Write, writer: &mut Write,
input_index: usize, input_index: usize,
@ -860,7 +860,7 @@ impl<R: Borrow<Transaction>> SighashCache<R> {
/// `script_code` is dependent on the type of the spend transaction. For p2wpkh use /// `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 /// [`Script::p2wpkh_script_code`], for p2wsh just pass in the witness script. (Also see
/// [`Self::p2wpkh_signature_hash`] and [`SighashCache::p2wsh_signature_hash`].) /// [`Self::p2wpkh_signature_hash`] and [`SighashCache::p2wsh_signature_hash`].)
pub fn segwit_v0_encode_signing_data_to<Write: io::Write>( pub fn segwit_v0_encode_signing_data_to<Write: io::Write + ?Sized>(
&mut self, &mut self,
writer: &mut Write, writer: &mut Write,
input_index: usize, input_index: usize,
@ -984,7 +984,7 @@ impl<R: Borrow<Transaction>> SighashCache<R> {
/// ///
/// This function can't handle the SIGHASH_SINGLE bug internally, so it returns [`EncodeSigningDataResult`] /// 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`]). /// that must be handled by the caller (see [`EncodeSigningDataResult::is_sighash_single_bug`]).
pub fn legacy_encode_signing_data_to<Write: io::Write, U: Into<u32>>( pub fn legacy_encode_signing_data_to<Write: io::Write + ?Sized, U: Into<u32>>(
&self, &self,
writer: &mut Write, writer: &mut Write,
input_index: usize, input_index: usize,
@ -1011,7 +1011,7 @@ impl<R: Borrow<Transaction>> SighashCache<R> {
return EncodeSigningDataResult::SighashSingleBug; return EncodeSigningDataResult::SighashSingleBug;
} }
fn encode_signing_data_to_inner<Write: io::Write>( fn encode_signing_data_to_inner<Write: io::Write + ?Sized>(
self_: &Transaction, self_: &Transaction,
writer: &mut Write, writer: &mut Write,
input_index: usize, input_index: usize,

View File

@ -1109,7 +1109,7 @@ impl TaprootMerkleBranch {
/// # Returns /// # Returns
/// ///
/// The number of bytes written to the writer. /// The number of bytes written to the writer.
pub fn encode<Write: io::Write>(&self, writer: &mut Write) -> io::Result<usize> { pub fn encode<Write: io::Write + ?Sized>(&self, writer: &mut Write) -> io::Result<usize> {
for hash in self.0.iter() { for hash in self.0.iter() {
writer.write_all(hash.as_ref())?; writer.write_all(hash.as_ref())?;
} }
@ -1237,7 +1237,7 @@ impl ControlBlock {
/// # Returns /// # Returns
/// ///
/// The number of bytes written to the writer. /// The number of bytes written to the writer.
pub fn encode<Write: io::Write>(&self, writer: &mut Write) -> io::Result<usize> { pub fn encode<Write: io::Write + ?Sized>(&self, writer: &mut Write) -> io::Result<usize> {
let first_byte: u8 = let first_byte: u8 =
i32::from(self.output_key_parity) as u8 | self.leaf_version.to_consensus(); i32::from(self.output_key_parity) as u8 | self.leaf_version.to_consensus();
writer.write_all(&[first_byte])?; writer.write_all(&[first_byte])?;