From 7befa66a372866f3016e5297b24c9652c90ad805 Mon Sep 17 00:00:00 2001 From: Innocent Onyemaenu Date: Fri, 10 Jan 2025 01:04:20 +0100 Subject: [PATCH] Fix up ParsePublickeyError In #3847 we added an `InvalidCharError` into one of the variants of `ParsePublicKeyError` but we forgot to update the trait implementations. Fix the `error::Error` and `Display` implementations for `ParsePublicKeyError`. While we are at it match on `*self` as is typical in this codebase. With this applied #3835 is fully resolved. Close: #3853 --- bitcoin/src/crypto/key.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs index e51350afab..81849f3c1b 100644 --- a/bitcoin/src/crypto/key.rs +++ b/bitcoin/src/crypto/key.rs @@ -1034,9 +1034,9 @@ impl From for ParsePublicKeyError { impl fmt::Display for ParsePublicKeyError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use ParsePublicKeyError::*; - match self { - Encoding(e) => write_err!(f, "string error"; e), - InvalidChar(char) => write!(f, "hex error {}", char), + match *self { + Encoding(ref e) => write_err!(f, "string error"; e), + InvalidChar(ref e) => write_err!(f, "hex decoding"; e), InvalidHexLength(got) => write!(f, "pubkey string should be 66 or 130 digits long, got: {}", got), } @@ -1048,9 +1048,10 @@ impl std::error::Error for ParsePublicKeyError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use ParsePublicKeyError::*; - match self { - Encoding(e) => Some(e), - InvalidChar(_) | InvalidHexLength(_) => None, + match *self { + Encoding(ref e) => Some(e), + InvalidChar(ref e) => Some(e), + InvalidHexLength(_) => None, } } }