units: Re-order impl_parse_str_from_int_infallible

We have a public macro `impl_parse_str_from_int_infallible` and a helper
macro used by it, both pubicly exported.

To assist readers understanding what is going on put the helper below
the other.

Code move only, no logic change.
This commit is contained in:
Tobin C. Harding 2024-12-18 11:22:32 +11:00
parent 4cd7a5e708
commit fc9e40ab1a
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 17 additions and 17 deletions

View File

@ -91,23 +91,6 @@ pub fn int<T: Integer, S: AsRef<str> + Into<InputString>>(s: S) -> Result<T, Par
})
}
/// Implements `TryFrom<$from> for $to` using `parse::int`, mapping the output using infallible
/// conversion function `fn`.
#[macro_export]
macro_rules! impl_tryfrom_str_from_int_infallible {
($($from:ty, $to:ident, $inner:ident, $fn:ident);*) => {
$(
impl $crate::_export::_core::convert::TryFrom<$from> for $to {
type Error = $crate::parse::ParseIntError;
fn try_from(s: $from) -> $crate::_export::_core::result::Result<Self, Self::Error> {
$crate::parse::int::<$inner, $from>(s).map($to::$fn)
}
}
)*
}
}
/// Implements `FromStr` and `TryFrom<{&str, String, Box<str>}> for $to` using `parse::int`, mapping
/// the output using infallible conversion function `fn`.
///
@ -130,6 +113,23 @@ macro_rules! impl_parse_str_from_int_infallible {
}
}
/// Implements `TryFrom<$from> for $to` using `parse::int`, mapping the output using infallible
/// conversion function `fn`.
#[macro_export]
macro_rules! impl_tryfrom_str_from_int_infallible {
($($from:ty, $to:ident, $inner:ident, $fn:ident);*) => {
$(
impl $crate::_export::_core::convert::TryFrom<$from> for $to {
type Error = $crate::parse::ParseIntError;
fn try_from(s: $from) -> $crate::_export::_core::result::Result<Self, Self::Error> {
$crate::parse::int::<$inner, $from>(s).map($to::$fn)
}
}
)*
}
}
/// Implements `TryFrom<$from> for $to`.
#[macro_export]
macro_rules! impl_tryfrom_str {