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.
This commit is contained in:
parent
4cc7aae6b9
commit
2675cd1040
|
@ -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<Self, Self::Error> {
|
||||
$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<Self, Self::Error> {
|
||||
$inner_fn(s)
|
||||
}
|
||||
}
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
/// Removes the prefix `0x` (or `0X`) from a hex string.
|
||||
///
|
||||
/// # Errors
|
||||
|
|
Loading…
Reference in New Issue