From fc9e40ab1a3582b29d553da73ac5a445a902a015 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 18 Dec 2024 11:22:32 +1100 Subject: [PATCH] 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. --- units/src/parse.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/units/src/parse.rs b/units/src/parse.rs index ec36d4b94..34cbfaba3 100644 --- a/units/src/parse.rs +++ b/units/src/parse.rs @@ -91,23 +91,6 @@ pub fn int + Into>(s: S) -> Result 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 { - $crate::parse::int::<$inner, $from>(s).map($to::$fn) - } - } - )* - } -} - /// Implements `FromStr` and `TryFrom<{&str, String, Box}> 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 { + $crate::parse::int::<$inner, $from>(s).map($to::$fn) + } + } + )* + } +} + /// Implements `TryFrom<$from> for $to`. #[macro_export] macro_rules! impl_tryfrom_str {