From 7e2a81d03b2c4df158d58d32049fc71a69b4fcc7 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 27 Feb 2024 11:10:03 +1100 Subject: [PATCH] Remove unused address::Error type --- bitcoin/src/address/error.rs | 42 ------------------------------------ bitcoin/src/address/mod.rs | 2 +- 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/bitcoin/src/address/error.rs b/bitcoin/src/address/error.rs index a61dcc73..e8018436 100644 --- a/bitcoin/src/address/error.rs +++ b/bitcoin/src/address/error.rs @@ -29,48 +29,6 @@ impl fmt::Display for NetworkValidationError { #[cfg(feature = "std")] impl std::error::Error for NetworkValidationError {} -/// Address error. -#[derive(Debug, Clone, PartialEq, Eq)] -#[non_exhaustive] -pub enum Error { - /// Address's network differs from required one. - NetworkValidation { - /// Network that was required. - required: Network, - /// The address itself - address: Address, - }, - /// Unknown hrp for current bitcoin networks (in bech32 address). - UnknownHrp(UnknownHrpError), -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use Error::*; - - match *self { - NetworkValidation { required, ref address } => { - write!(f, "address ")?; - fmt::Display::fmt(&address.0, f)?; - write!(f, " is not valid on {}", required) - } - Error::UnknownHrp(ref e) => write_err!(f, "unknown hrp"; e), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for Error { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use Error::*; - - match *self { - UnknownHrp(ref e) => Some(e), - NetworkValidation { .. } => None, - } - } -} - /// Error while generating address from script. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] diff --git a/bitcoin/src/address/mod.rs b/bitcoin/src/address/mod.rs index ac3e6b8b..7bb66e12 100644 --- a/bitcoin/src/address/mod.rs +++ b/bitcoin/src/address/mod.rs @@ -55,7 +55,7 @@ use self::error::P2shError; #[rustfmt::skip] // Keep public re-exports separate. #[doc(inline)] pub use self::{ - error::{Error, NetworkValidationError, ParseError, UnknownAddressTypeError, UnknownHrpError, FromScriptError, }, + error::{NetworkValidationError, ParseError, UnknownAddressTypeError, UnknownHrpError, FromScriptError, }, }; /// The different types of addresses.