diff options
| author | rickdewater <rick_water@hotmail.com> | 2024-10-07 22:35:54 +0200 |
|---|---|---|
| committer | rickdewater <rick_water@hotmail.com> | 2024-10-08 12:09:03 +0200 |
| commit | fead1d5634f8badb0dd8436032334916bfdff7e4 (patch) | |
| tree | b12cac82439665a0e5dc691d0f041135d1dcce5a /library/core/src | |
| parent | 7caad6925314911eefe54b040d4bc5be940e8f92 (diff) | |
| download | rust-fead1d5634f8badb0dd8436032334916bfdff7e4.tar.gz rust-fead1d5634f8badb0dd8436032334916bfdff7e4.zip | |
Add LowerExp and UpperExp implementations
Mark the new fmt impls with the correct rust version Clean up the fmt macro and format the tests
Diffstat (limited to 'library/core/src')
| -rw-r--r-- | library/core/src/num/nonzero.rs | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index e5c9a7e086a..512c7ffa305 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -110,26 +110,40 @@ impl_zeroable_primitive!( pub struct NonZero<T: ZeroablePrimitive>(T::NonZeroInner); macro_rules! impl_nonzero_fmt { - ($Trait:ident) => { - #[stable(feature = "nonzero", since = "1.28.0")] - impl<T> fmt::$Trait for NonZero<T> - where - T: ZeroablePrimitive + fmt::$Trait, - { - #[inline] - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.get().fmt(f) + ($(#[$Attribute:meta] $Trait:ident)*) => { + $( + #[$Attribute] + impl<T> fmt::$Trait for NonZero<T> + where + T: ZeroablePrimitive + fmt::$Trait, + { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.get().fmt(f) + } } - } + )* }; } -impl_nonzero_fmt!(Debug); -impl_nonzero_fmt!(Display); -impl_nonzero_fmt!(Binary); -impl_nonzero_fmt!(Octal); -impl_nonzero_fmt!(LowerHex); -impl_nonzero_fmt!(UpperHex); +impl_nonzero_fmt! { + #[stable(feature = "nonzero", since = "1.28.0")] + Debug + #[stable(feature = "nonzero", since = "1.28.0")] + Display + #[stable(feature = "nonzero", since = "1.28.0")] + Binary + #[stable(feature = "nonzero", since = "1.28.0")] + Octal + #[stable(feature = "nonzero", since = "1.28.0")] + LowerHex + #[stable(feature = "nonzero", since = "1.28.0")] + UpperHex + #[stable(feature = "nonzero_fmt_exp", since = "CURRENT_RUSTC_VERSION")] + LowerExp + #[stable(feature = "nonzero_fmt_exp", since = "CURRENT_RUSTC_VERSION")] + UpperExp +} macro_rules! impl_nonzero_auto_trait { (unsafe $Trait:ident) => { |
