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.
This commit is contained in:
Tobin C. Harding 2023-10-04 12:11:07 +11:00
parent bd9c4125cf
commit 39314ad52f
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 10 additions and 10 deletions

View File

@ -35,14 +35,6 @@ impl ParseIntError {
pub fn input(&self) -> &str { &self.input } pub fn input(&self) -> &str { &self.input }
} }
impl From<ParseIntError> for core::num::ParseIntError {
fn from(value: ParseIntError) -> Self { value.source }
}
impl AsRef<core::num::ParseIntError> for ParseIntError {
fn as_ref(&self) -> &core::num::ParseIntError { &self.source }
}
impl fmt::Display for ParseIntError { impl fmt::Display for ParseIntError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let signed = if self.is_signed { "signed" } else { "unsigned" }; 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<ParseIntError> for core::num::ParseIntError {
fn from(value: ParseIntError) -> Self { value.source }
}
impl AsRef<core::num::ParseIntError> 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 /// Not strictly neccessary but serves as a lint - avoids weird behavior if someone accidentally
/// passes non-integer to the `parse()` function. /// passes non-integer to the `parse()` function.
pub(crate) trait Integer: pub(crate) trait Integer:
@ -95,8 +97,6 @@ pub(crate) fn hex_u32<S: AsRef<str> + Into<String>>(s: S) -> Result<u32, ParseIn
}) })
} }
impl_std_error!(ParseIntError, source);
/// Implements `TryFrom<$from> for $to` using `parse::int`, mapping the output using infallible /// Implements `TryFrom<$from> for $to` using `parse::int`, mapping the output using infallible
/// conversion function `fn`. /// conversion function `fn`.
macro_rules! impl_tryfrom_str_from_int_infallible { macro_rules! impl_tryfrom_str_from_int_infallible {