Move 'impl FromStr for NonZero' into nonzero_integer macro

This commit is contained in:
David Tolnay 2023-12-05 18:28:52 -08:00
parent a6152cdd9a
commit 3de0af1a4d
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -190,13 +190,9 @@ macro_rules! nonzero_integer {
#[stable(feature = $feature, since = $since)]
(Debug, Display, Binary, Octal, LowerHex, UpperHex) for $Ty
}
};
}
macro_rules! from_str_radix_nzint_impl {
($($t:ty)*) => {$(
#[stable(feature = "nonzero_parse", since = "1.35.0")]
impl FromStr for $t {
impl FromStr for $Ty {
type Err = ParseIntError;
fn from_str(src: &str) -> Result<Self, Self::Err> {
Self::new(from_str_radix(src, 10)?)
@ -205,12 +201,9 @@ macro_rules! from_str_radix_nzint_impl {
})
}
}
)*}
};
}
from_str_radix_nzint_impl! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroU128 NonZeroUsize
NonZeroI8 NonZeroI16 NonZeroI32 NonZeroI64 NonZeroI128 NonZeroIsize }
macro_rules! nonzero_leading_trailing_zeros {
( $( $Ty: ident($Uint: ty) , $LeadingTestExpr:expr ;)+ ) => {
$(