From 39314ad52f65039ec29fd8ad3a1b482cdeeaebe4 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 4 Oct 2023 12:11:07 +1100 Subject: [PATCH] Move error code to match conventional layout We typically layout error code as: definition, [impl block], `Display` impl, `error::Error` impl, from imlps. Code move only, no other changes. --- bitcoin/src/parse.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bitcoin/src/parse.rs b/bitcoin/src/parse.rs index 3e04f5ae..8d5a9813 100644 --- a/bitcoin/src/parse.rs +++ b/bitcoin/src/parse.rs @@ -35,14 +35,6 @@ impl ParseIntError { pub fn input(&self) -> &str { &self.input } } -impl From for core::num::ParseIntError { - fn from(value: ParseIntError) -> Self { value.source } -} - -impl AsRef for ParseIntError { - fn as_ref(&self) -> &core::num::ParseIntError { &self.source } -} - impl fmt::Display for ParseIntError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let signed = if self.is_signed { "signed" } else { "unsigned" }; @@ -51,6 +43,16 @@ impl fmt::Display for ParseIntError { } } +impl_std_error!(ParseIntError, source); + +impl From for core::num::ParseIntError { + fn from(value: ParseIntError) -> Self { value.source } +} + +impl AsRef for ParseIntError { + fn as_ref(&self) -> &core::num::ParseIntError { &self.source } +} + /// Not strictly neccessary but serves as a lint - avoids weird behavior if someone accidentally /// passes non-integer to the `parse()` function. pub(crate) trait Integer: @@ -95,8 +97,6 @@ pub(crate) fn hex_u32 + Into>(s: S) -> Result for $to` using `parse::int`, mapping the output using infallible /// conversion function `fn`. macro_rules! impl_tryfrom_str_from_int_infallible {