From 2675cd1040cfe254a9258c080a65ab253c8f9250 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 18 Dec 2024 11:24:39 +1100 Subject: [PATCH] units: Re-order impl_parse_str We have a public macro `impl_parse_str` and a helper macro used by it, both pubicly exported. As we did for `impl_parse_str_from_int_infallible`; to assist readers understanding what is going on put the helper below the other. Done as a separate patch to make the diff easier to read. Internal change only, no logic change. --- units/src/parse.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/units/src/parse.rs b/units/src/parse.rs index 398a87798..d1f402dec 100644 --- a/units/src/parse.rs +++ b/units/src/parse.rs @@ -131,22 +131,6 @@ macro_rules! impl_tryfrom_str_from_int_infallible { } } -/// Implements `TryFrom<$from> for $to`. -#[macro_export] -macro_rules! impl_tryfrom_str { - ($($from:ty, $to:ty, $err:ty, $inner_fn:expr);*) => { - $( - impl $crate::_export::_core::convert::TryFrom<$from> for $to { - type Error = $err; - - fn try_from(s: $from) -> $crate::_export::_core::result::Result { - $inner_fn(s) - } - } - )* - } -} - /// Implements standard parsing traits for `$type` by calling into `$inner_fn`. #[macro_export] macro_rules! impl_parse_str { @@ -165,6 +149,22 @@ macro_rules! impl_parse_str { } } +/// Implements `TryFrom<$from> for $to`. +#[macro_export] +macro_rules! impl_tryfrom_str { + ($($from:ty, $to:ty, $err:ty, $inner_fn:expr);*) => { + $( + impl $crate::_export::_core::convert::TryFrom<$from> for $to { + type Error = $err; + + fn try_from(s: $from) -> $crate::_export::_core::result::Result { + $inner_fn(s) + } + } + )* + } +} + /// Removes the prefix `0x` (or `0X`) from a hex string. /// /// # Errors