about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2023-12-05 22:49:44 -0800
committerDavid Tolnay <dtolnay@gmail.com>2024-01-14 12:45:44 -0800
commit7f7c5af097678da556cd57936a8d8b6c02858502 (patch)
tree0f5c71e2e0960bf4b4dc21061c7b52cf5c48f4a3
parent441913626d33919b743e167c5c9e951487291fdd (diff)
downloadrust-7f7c5af097678da556cd57936a8d8b6c02858502.tar.gz
rust-7f7c5af097678da556cd57936a8d8b6c02858502.zip
Move unsigned MIN and MAX into signedness_dependent_methods
-rw-r--r--library/core/src/num/nonzero.rs69
1 files changed, 26 insertions, 43 deletions
diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs
index 0c34012ab5c..0ab89aa0d6c 100644
--- a/library/core/src/num/nonzero.rs
+++ b/library/core/src/num/nonzero.rs
@@ -515,12 +515,37 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
 
 #[rustfmt::skip] // https://github.com/rust-lang/rustfmt/issues/5974
 macro_rules! nonzero_integer_signedness_dependent_methods {
-    // Methods for unsigned nonzero types only.
+    // Associated items for unsigned nonzero types only.
     (
         Self = $Ty:ident,
         Primitive = unsigned $Int:ident,
         UnsignedPrimitive = $Uint:ty,
     ) => {
+        /// The smallest value that can be represented by this non-zero
+        /// integer type, 1.
+        ///
+        /// # Examples
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN.get(), 1", stringify!($Int), ");")]
+        /// ```
+        #[stable(feature = "nonzero_min_max", since = "1.70.0")]
+        pub const MIN: Self = Self::new(1).unwrap();
+
+        /// The largest value that can be represented by this non-zero
+        /// integer type,
+        #[doc = concat!("equal to [`", stringify!($Int), "::MAX`].")]
+        ///
+        /// # Examples
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX.get(), ", stringify!($Int), "::MAX);")]
+        /// ```
+        #[stable(feature = "nonzero_min_max", since = "1.70.0")]
+        pub const MAX: Self = Self::new(<$Int>::MAX).unwrap();
+
         /// Adds an unsigned integer to a non-zero value.
         /// Checks for overflow and returns [`None`] on overflow.
         /// As a consequence, the result cannot wrap to zero.
@@ -1177,39 +1202,6 @@ macro_rules! sign_dependent_expr {
     };
 }
 
-macro_rules! nonzero_min_max_unsigned {
-    ( $( $Ty: ident($Int: ident); )+ ) => {
-        $(
-            impl $Ty {
-                /// The smallest value that can be represented by this non-zero
-                /// integer type, 1.
-                ///
-                /// # Examples
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                #[doc = concat!("assert_eq!(", stringify!($Ty), "::MIN.get(), 1", stringify!($Int), ");")]
-                /// ```
-                #[stable(feature = "nonzero_min_max", since = "1.70.0")]
-                pub const MIN: Self = Self::new(1).unwrap();
-
-                /// The largest value that can be represented by this non-zero
-                /// integer type,
-                #[doc = concat!("equal to [`", stringify!($Int), "::MAX`].")]
-                ///
-                /// # Examples
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                #[doc = concat!("assert_eq!(", stringify!($Ty), "::MAX.get(), ", stringify!($Int), "::MAX);")]
-                /// ```
-                #[stable(feature = "nonzero_min_max", since = "1.70.0")]
-                pub const MAX: Self = Self::new(<$Int>::MAX).unwrap();
-            }
-        )+
-    }
-}
-
 macro_rules! nonzero_min_max_signed {
     ( $( $Ty: ident($Int: ident); )+ ) => {
         $(
@@ -1252,15 +1244,6 @@ macro_rules! nonzero_min_max_signed {
     }
 }
 
-nonzero_min_max_unsigned! {
-    NonZeroU8(u8);
-    NonZeroU16(u16);
-    NonZeroU32(u32);
-    NonZeroU64(u64);
-    NonZeroU128(u128);
-    NonZeroUsize(usize);
-}
-
 nonzero_min_max_signed! {
     NonZeroI8(i8);
     NonZeroI16(i16);