From 482c8cb7f8e172091dba1592ef49fbc415f33987 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 6 Feb 2024 12:48:22 +1100 Subject: [PATCH] Clean up error type from impls Make the `From` impls conform to our convention. Refactor only, no logic changes. --- bitcoin/src/crypto/ecdsa.rs | 6 +++--- bitcoin/src/crypto/key.rs | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bitcoin/src/crypto/ecdsa.rs b/bitcoin/src/crypto/ecdsa.rs index aaf8046a..fd5cb4ae 100644 --- a/bitcoin/src/crypto/ecdsa.rs +++ b/bitcoin/src/crypto/ecdsa.rs @@ -241,15 +241,15 @@ impl std::error::Error for Error { } impl From for Error { - fn from(e: secp256k1::Error) -> Error { Error::Secp256k1(e) } + fn from(e: secp256k1::Error) -> Self { Self::Secp256k1(e) } } impl From for Error { - fn from(err: NonStandardSighashTypeError) -> Self { Error::SighashType(err) } + fn from(e: NonStandardSighashTypeError) -> Self { Self::SighashType(e) } } impl From for Error { - fn from(err: hex::HexToBytesError) -> Self { Error::Hex(err) } + fn from(e: hex::HexToBytesError) -> Self { Self::Hex(e) } } #[cfg(test)] diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs index 364a946c..4bc8b3fb 100644 --- a/bitcoin/src/crypto/key.rs +++ b/bitcoin/src/crypto/key.rs @@ -921,7 +921,7 @@ impl std::error::Error for FromSliceError { } impl From for FromSliceError { - fn from(e: secp256k1::Error) -> FromSliceError { Self::Secp256k1(e) } + fn from(e: secp256k1::Error) -> Self { Self::Secp256k1(e) } } /// Error generated from WIF key format. @@ -956,11 +956,11 @@ impl std::error::Error for FromWifError { } impl From for FromWifError { - fn from(e: base58::Error) -> FromWifError { Self::Base58(e) } + fn from(e: base58::Error) -> Self { Self::Base58(e) } } impl From for FromWifError { - fn from(e: secp256k1::Error) -> FromWifError { Self::Secp256k1(e) } + fn from(e: secp256k1::Error) -> Self { Self::Secp256k1(e) } } /// Error returned while constructing public key from string. @@ -1033,11 +1033,11 @@ impl std::error::Error for ParseCompressedPublicKeyError { } impl From for ParseCompressedPublicKeyError { - fn from(e: secp256k1::Error) -> ParseCompressedPublicKeyError { Self::Secp256k1(e) } + fn from(e: secp256k1::Error) -> Self { Self::Secp256k1(e) } } impl From for ParseCompressedPublicKeyError { - fn from(e: hex::HexToArrayError) -> ParseCompressedPublicKeyError { Self::HexError(e) } + fn from(e: hex::HexToArrayError) -> Self { Self::HexError(e) } } /// Segwit public keys must always be compressed.