taproot: Use error variants locally

Add 'use Error::*' locally to make the code more terse.
This commit is contained in:
Tobin C. Harding 2023-06-02 14:48:22 +10:00
parent 6a04ca12e0
commit d86517ae4f
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 6 additions and 5 deletions

View File

@ -73,12 +73,13 @@ pub enum Error {
impl fmt::Display for Error { impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use Error::*;
match *self { match *self {
Error::InvalidSighashType(hash_ty) => InvalidSighashType(hash_ty) => write!(f, "invalid signature hash type {}", hash_ty),
write!(f, "invalid signature hash type {}", hash_ty), Secp256k1(ref e) =>
Error::Secp256k1(ref e) =>
write_err!(f, "taproot signature has correct len but is malformed"; 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")] #[cfg(feature = "std")]
impl std::error::Error for Error { impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
use self::Error::*; use Error::*;
match self { match self {
Secp256k1(e) => Some(e), Secp256k1(e) => Some(e),