diff --git a/src/blockdata/script.rs b/src/blockdata/script.rs index 3d42d741..8cb468f0 100644 --- a/src/blockdata/script.rs +++ b/src/blockdata/script.rs @@ -422,7 +422,7 @@ impl Script { } /// Write the assembly decoding of the script to the formatter. - pub fn fmt_asm(&self, f: &mut fmt::Write) -> fmt::Result { + pub fn fmt_asm(&self, f: &mut dyn fmt::Write) -> fmt::Result { let mut index = 0; while index < self.0.len() { let opcode = opcodes::All::from(self.0[index]); diff --git a/src/blockdata/transaction.rs b/src/blockdata/transaction.rs index c9ce726b..06f36a85 100644 --- a/src/blockdata/transaction.rs +++ b/src/blockdata/transaction.rs @@ -24,7 +24,7 @@ //! use std::default::Default; -use std::{fmt, io}; +use std::{error, fmt, io}; use hashes::{self, Hash, sha256d}; use hashes::hex::FromHex; @@ -129,12 +129,12 @@ impl fmt::Display for ParseOutPointError { } #[allow(deprecated)] -impl ::std::error::Error for ParseOutPointError { +impl error::Error for ParseOutPointError { fn description(&self) -> &str { "description() is deprecated; use Display" } - fn cause(&self) -> Option<&::std::error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { match *self { ParseOutPointError::Txid(ref e) => Some(e), ParseOutPointError::Vout(ref e) => Some(e), diff --git a/src/consensus/encode.rs b/src/consensus/encode.rs index 8e3f3768..32aa9512 100644 --- a/src/consensus/encode.rs +++ b/src/consensus/encode.rs @@ -111,7 +111,7 @@ impl fmt::Display for Error { #[allow(deprecated)] impl error::Error for Error { - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { match *self { Error::Io(ref e) => Some(e), Error::Psbt(ref e) => Some(e), diff --git a/src/network/mod.rs b/src/network/mod.rs index de8ee96a..c541f186 100644 --- a/src/network/mod.rs +++ b/src/network/mod.rs @@ -66,7 +66,7 @@ impl error::Error for Error { "description() is deprecated; use Display" } - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { match *self { Error::Io(ref e) => Some(e), Error::SocketMutexPoisoned | Error::SocketNotConnectedToPeer => None, diff --git a/src/util/address.rs b/src/util/address.rs index 771926ce..17361575 100644 --- a/src/util/address.rs +++ b/src/util/address.rs @@ -38,6 +38,7 @@ use std::fmt::{self, Display, Formatter}; use std::str::FromStr; +use std::error; use bech32; use hashes::Hash; @@ -87,8 +88,8 @@ impl fmt::Display for Error { } #[allow(deprecated)] -impl ::std::error::Error for Error { - fn cause(&self) -> Option<&::std::error::Error> { +impl error::Error for Error { + fn cause(&self) -> Option<&dyn error::Error> { match *self { Error::Base58(ref e) => Some(e), Error::Bech32(ref e) => Some(e), diff --git a/src/util/amount.rs b/src/util/amount.rs index b9c9c537..5d37e36c 100644 --- a/src/util/amount.rs +++ b/src/util/amount.rs @@ -215,7 +215,7 @@ fn parse_signed_to_satoshi( fn fmt_satoshi_in( satoshi: u64, negative: bool, - f: &mut fmt::Write, + f: &mut dyn fmt::Write, denom: Denomination, ) -> fmt::Result { if negative { @@ -365,7 +365,7 @@ impl Amount { /// Format the value of this [Amount] in the given denomination. /// /// Does not include the denomination. - pub fn fmt_value_in(self, f: &mut fmt::Write, denom: Denomination) -> fmt::Result { + pub fn fmt_value_in(self, f: &mut dyn fmt::Write, denom: Denomination) -> fmt::Result { fmt_satoshi_in(self.as_sat(), false, f, denom) } @@ -643,7 +643,7 @@ impl SignedAmount { /// Format the value of this [SignedAmount] in the given denomination. /// /// Does not include the denomination. - pub fn fmt_value_in(self, f: &mut fmt::Write, denom: Denomination) -> fmt::Result { + pub fn fmt_value_in(self, f: &mut dyn fmt::Write, denom: Denomination) -> fmt::Result { let sats = self.as_sat().checked_abs().map(|a: i64| a as u64).unwrap_or_else(|| { // We could also hard code this into `9223372036854775808` u64::max_value() - self.as_sat() as u64 +1 diff --git a/src/util/bip158.rs b/src/util/bip158.rs index 26381345..76e62887 100644 --- a/src/util/bip158.rs +++ b/src/util/bip158.rs @@ -133,13 +133,13 @@ impl BlockFilter { } /// match any query pattern - pub fn match_any(&self, block_hash: &BlockHash, query: &mut Iterator) -> Result { + pub fn match_any(&self, block_hash: &BlockHash, query: &mut dyn Iterator) -> Result { let filter_reader = BlockFilterReader::new(block_hash); filter_reader.match_any(&mut Cursor::new(self.content.as_slice()), query) } /// match all query pattern - pub fn match_all(&self, block_hash: &BlockHash, query: &mut Iterator) -> Result { + pub fn match_all(&self, block_hash: &BlockHash, query: &mut dyn Iterator) -> Result { let filter_reader = BlockFilterReader::new(block_hash); filter_reader.match_all(&mut Cursor::new(self.content.as_slice()), query) } @@ -153,7 +153,7 @@ pub struct BlockFilterWriter<'a> { impl<'a> BlockFilterWriter<'a> { /// Create a block filter writer - pub fn new(writer: &'a mut io::Write, block: &'a Block) -> BlockFilterWriter<'a> { + pub fn new(writer: &'a mut dyn io::Write, block: &'a Block) -> BlockFilterWriter<'a> { let block_hash_as_int = block.block_hash().into_inner(); let k0 = endian::slice_to_u64_le(&block_hash_as_int[0..8]); let k1 = endian::slice_to_u64_le(&block_hash_as_int[8..16]); @@ -214,12 +214,12 @@ impl BlockFilterReader { } /// match any query pattern - pub fn match_any(&self, reader: &mut io::Read, query: &mut Iterator) -> Result { + pub fn match_any(&self, reader: &mut dyn io::Read, query: &mut dyn Iterator) -> Result { self.reader.match_any(reader, query) } /// match all query pattern - pub fn match_all(&self, reader: &mut io::Read, query: &mut Iterator) -> Result { + pub fn match_all(&self, reader: &mut dyn io::Read, query: &mut dyn Iterator) -> Result { self.reader.match_all(reader, query) } } @@ -238,7 +238,7 @@ impl GCSFilterReader { } /// match any query pattern - pub fn match_any(&self, reader: &mut io::Read, query: &mut Iterator) -> Result { + pub fn match_any(&self, reader: &mut dyn io::Read, query: &mut dyn Iterator) -> Result { let mut decoder = reader; let n_elements: VarInt = Decodable::consensus_decode(&mut decoder).unwrap_or(VarInt(0)); let reader = &mut decoder; @@ -278,7 +278,7 @@ impl GCSFilterReader { } /// match all query pattern - pub fn match_all(&self, reader: &mut io::Read, query: &mut Iterator) -> Result { + pub fn match_all(&self, reader: &mut dyn io::Read, query: &mut dyn Iterator) -> Result { let mut decoder = reader; let n_elements: VarInt = Decodable::consensus_decode(&mut decoder).unwrap_or(VarInt(0)); let reader = &mut decoder; @@ -340,14 +340,14 @@ fn map_to_range(hash: u64, nm: u64) -> u64 { /// Colomb-Rice encoded filter writer pub struct GCSFilterWriter<'a> { filter: GCSFilter, - writer: &'a mut io::Write, + writer: &'a mut dyn io::Write, elements: HashSet>, m: u64 } impl<'a> GCSFilterWriter<'a> { /// Create a new GCS writer wrapping a generic writer, with specific seed to siphash - pub fn new(writer: &'a mut io::Write, k0: u64, k1: u64, m: u64, p: u8) -> GCSFilterWriter<'a> { + pub fn new(writer: &'a mut dyn io::Write, k0: u64, k1: u64, m: u64, p: u8) -> GCSFilterWriter<'a> { GCSFilterWriter { filter: GCSFilter::new(k0, k1, p), writer, @@ -436,12 +436,12 @@ impl GCSFilter { pub struct BitStreamReader<'a> { buffer: [u8; 1], offset: u8, - reader: &'a mut io::Read, + reader: &'a mut dyn io::Read, } impl<'a> BitStreamReader<'a> { /// Create a new BitStreamReader that reads bitwise from a given reader - pub fn new(reader: &'a mut io::Read) -> BitStreamReader { + pub fn new(reader: &'a mut dyn io::Read) -> BitStreamReader { BitStreamReader { buffer: [0u8], reader: reader, @@ -474,12 +474,12 @@ impl<'a> BitStreamReader<'a> { pub struct BitStreamWriter<'a> { buffer: [u8; 1], offset: u8, - writer: &'a mut io::Write, + writer: &'a mut dyn io::Write, } impl<'a> BitStreamWriter<'a> { /// Create a new BitStreamWriter that writes bitwise to a given writer - pub fn new(writer: &'a mut io::Write) -> BitStreamWriter { + pub fn new(writer: &'a mut dyn io::Write) -> BitStreamWriter { BitStreamWriter { buffer: [0u8], writer: writer, diff --git a/src/util/bip32.rs b/src/util/bip32.rs index e1815e03..8d6dcf50 100644 --- a/src/util/bip32.rs +++ b/src/util/bip32.rs @@ -404,7 +404,7 @@ impl fmt::Display for Error { } impl error::Error for Error { - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { if let Error::Ecdsa(ref e) = *self { Some(e) } else { diff --git a/src/util/contracthash.rs b/src/util/contracthash.rs index fa893f2d..cc53a817 100644 --- a/src/util/contracthash.rs +++ b/src/util/contracthash.rs @@ -73,7 +73,7 @@ impl fmt::Display for Error { #[allow(deprecated)] impl error::Error for Error { - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { match *self { Error::Secp(ref e) => Some(e), Error::Script(ref e) => Some(e), diff --git a/src/util/key.rs b/src/util/key.rs index f36c206d..83b56965 100644 --- a/src/util/key.rs +++ b/src/util/key.rs @@ -46,7 +46,7 @@ impl fmt::Display for Error { } impl error::Error for Error { - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { match *self { Error::Base58(ref e) => Some(e), Error::Secp256k1(ref e) => Some(e), @@ -193,7 +193,7 @@ impl PrivateKey { } /// Format the private key to WIF format. - pub fn fmt_wif(&self, fmt: &mut fmt::Write) -> fmt::Result { + pub fn fmt_wif(&self, fmt: &mut dyn fmt::Write) -> fmt::Result { let mut ret = [0; 34]; ret[0] = match self.network { Network::Bitcoin => 128, diff --git a/src/util/mod.rs b/src/util/mod.rs index 856757d8..523c4377 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -85,7 +85,7 @@ impl fmt::Display for Error { #[allow(deprecated)] impl error::Error for Error { - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { match *self { Error::Encode(ref e) => Some(e), Error::Network(ref e) => Some(e),