diff --git a/primitives/src/transaction.rs b/primitives/src/transaction.rs index 10176ef76..ef322e62b 100644 --- a/primitives/src/transaction.rs +++ b/primitives/src/transaction.rs @@ -471,14 +471,12 @@ impl From for ParseOutPointError { #[cfg(feature = "hex")] impl fmt::Display for ParseOutPointError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ParseOutPointError as E; - match *self { - E::Txid(ref e) => write_err!(f, "error parsing TXID"; e), - E::Vout(ref e) => write_err!(f, "error parsing vout"; e), - E::Format => write!(f, "OutPoint not in : format"), - E::TooLong => write!(f, "vout should be at most 10 digits"), - E::VoutNotCanonical => write!(f, "no leading zeroes or + allowed in vout part"), + Self::Txid(ref e) => write_err!(f, "error parsing TXID"; e), + Self::Vout(ref e) => write_err!(f, "error parsing vout"; e), + Self::Format => write!(f, "OutPoint not in : format"), + Self::TooLong => write!(f, "vout should be at most 10 digits"), + Self::VoutNotCanonical => write!(f, "no leading zeroes or + allowed in vout part"), } } } @@ -487,12 +485,10 @@ impl fmt::Display for ParseOutPointError { #[cfg(feature = "hex")] impl std::error::Error for ParseOutPointError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ParseOutPointError as E; - match self { - E::Txid(e) => Some(e), - E::Vout(e) => Some(e), - E::Format | E::TooLong | E::VoutNotCanonical => None, + Self::Txid(e) => Some(e), + Self::Vout(e) => Some(e), + Self::Format | Self::TooLong | Self::VoutNotCanonical => None, } } } diff --git a/units/src/amount/error.rs b/units/src/amount/error.rs index dd06db041..fbb1cfdfd 100644 --- a/units/src/amount/error.rs +++ b/units/src/amount/error.rs @@ -337,11 +337,9 @@ impl From for ParseDenominationError { impl fmt::Display for ParseDenominationError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use ParseDenominationError as E; - match *self { - E::Unknown(ref e) => write_err!(f, "denomination parse error"; e), - E::PossiblyConfusing(ref e) => write_err!(f, "denomination parse error"; e), + Self::Unknown(ref e) => write_err!(f, "denomination parse error"; e), + Self::PossiblyConfusing(ref e) => write_err!(f, "denomination parse error"; e), } } } @@ -349,10 +347,9 @@ impl fmt::Display for ParseDenominationError { #[cfg(feature = "std")] impl std::error::Error for ParseDenominationError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use ParseDenominationError as E; match *self { - E::Unknown(_) | E::PossiblyConfusing(_) => None, + Self::Unknown(_) | Self::PossiblyConfusing(_) => None, } } } diff --git a/units/src/locktime/absolute.rs b/units/src/locktime/absolute.rs index f80ccdfee..ee50262ef 100644 --- a/units/src/locktime/absolute.rs +++ b/units/src/locktime/absolute.rs @@ -377,10 +377,9 @@ impl ParseError { ) -> fmt::Result { use core::num::IntErrorKind; - use ParseError as E; match self { - E::ParseInt(ParseIntError { input, bits: _, is_signed: _, source }) + Self::ParseInt(ParseIntError { input, bits: _, is_signed: _, source }) if *source.kind() == IntErrorKind::PosOverflow => { // Outputs "failed to parse as absolute Height/MedianTimePast ( is above limit )" @@ -392,7 +391,7 @@ impl ParseError { upper_bound ) } - E::ParseInt(ParseIntError { input, bits: _, is_signed: _, source }) + Self::ParseInt(ParseIntError { input, bits: _, is_signed: _, source }) if *source.kind() == IntErrorKind::NegOverflow => { // Outputs "failed to parse as absolute Height/MedianTimePast ( is below limit )" @@ -404,7 +403,7 @@ impl ParseError { lower_bound ) } - E::ParseInt(ParseIntError { input, bits: _, is_signed: _, source: _ }) => { + Self::ParseInt(ParseIntError { input, bits: _, is_signed: _, source: _ }) => { write!( f, "{} ({})", @@ -412,10 +411,10 @@ impl ParseError { subject ) } - E::Conversion(value) if *value < i64::from(lower_bound) => { + Self::Conversion(value) if *value < i64::from(lower_bound) => { write!(f, "{} {} is below limit {}", subject, value, lower_bound) } - E::Conversion(value) => { + Self::Conversion(value) => { write!(f, "{} {} is above limit {}", subject, value, upper_bound) } } @@ -426,17 +425,16 @@ impl ParseError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use core::num::IntErrorKind; - use ParseError as E; match self { - E::ParseInt(ParseIntError { source, .. }) + Self::ParseInt(ParseIntError { source, .. }) if *source.kind() == IntErrorKind::PosOverflow => None, - E::ParseInt(ParseIntError { source, .. }) + Self::ParseInt(ParseIntError { source, .. }) if *source.kind() == IntErrorKind::NegOverflow => None, - E::ParseInt(ParseIntError { source, .. }) => Some(source), - E::Conversion(_) => None, + Self::ParseInt(ParseIntError { source, .. }) => Some(source), + Self::Conversion(_) => None, } } }