From d86517ae4fa70fbdcc792518c3fce88396ac9e4c Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 2 Jun 2023 14:48:22 +1000 Subject: [PATCH] taproot: Use error variants locally Add 'use Error::*' locally to make the code more terse. --- bitcoin/src/crypto/taproot.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bitcoin/src/crypto/taproot.rs b/bitcoin/src/crypto/taproot.rs index ffb34c63..96067bee 100644 --- a/bitcoin/src/crypto/taproot.rs +++ b/bitcoin/src/crypto/taproot.rs @@ -73,12 +73,13 @@ pub enum Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use Error::*; + match *self { - Error::InvalidSighashType(hash_ty) => - write!(f, "invalid signature hash type {}", hash_ty), - Error::Secp256k1(ref e) => + InvalidSighashType(hash_ty) => write!(f, "invalid signature hash type {}", hash_ty), + Secp256k1(ref e) => write_err!(f, "taproot signature has correct len but is malformed"; e), - Error::InvalidSignatureSize(sz) => write!(f, "invalid taproot signature size: {}", sz), + InvalidSignatureSize(sz) => write!(f, "invalid taproot signature size: {}", sz), } } } @@ -86,7 +87,7 @@ impl fmt::Display for Error { #[cfg(feature = "std")] impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use self::Error::*; + use Error::*; match self { Secp256k1(e) => Some(e),