about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2023-12-05 22:06:40 -0800
committerDavid Tolnay <dtolnay@gmail.com>2024-01-14 12:45:37 -0800
commitb21b9cc901c3f021c7b7475c406662cd9c0d76e1 (patch)
tree940e618aaf7e30c7cc99bb0a9f42db5c100899fa
parent4291b3ff62e4aad3dae4c573bde5f203d3baec79 (diff)
downloadrust-b21b9cc901c3f021c7b7475c406662cd9c0d76e1.tar.gz
rust-b21b9cc901c3f021c7b7475c406662cd9c0d76e1.zip
Unindent nonzero_integer_signedness_dependent_methods macro body
-rw-r--r--library/core/src/num/nonzero.rs1178
1 files changed, 589 insertions, 589 deletions
diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs
index 1b8920f9477..8550a7b4c7b 100644
--- a/library/core/src/num/nonzero.rs
+++ b/library/core/src/num/nonzero.rs
@@ -319,235 +319,235 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
         Primitive = unsigned $Int:ident,
         UnsignedPrimitive = $Uint:ty,
     ) => {
-                /// 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.
-                ///
-                ///
-                /// # Examples
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let one = ", stringify!($Ty), "::new(1)?;")]
-                #[doc = concat!("let two = ", stringify!($Ty), "::new(2)?;")]
-                #[doc = concat!("let max = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MAX)?;")]
-                ///
-                /// assert_eq!(Some(two), one.checked_add(1));
-                /// assert_eq!(None, max.checked_add(1));
-                /// # Some(())
-                /// # }
-                /// ```
-                #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
-                #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
-                #[must_use = "this returns the result of the operation, \
-                              without modifying the original"]
-                #[inline]
-                pub const fn checked_add(self, other: $Int) -> Option<$Ty> {
-                    if let Some(result) = self.get().checked_add(other) {
-                        // SAFETY:
-                        // - `checked_add` returns `None` on overflow
-                        // - `self` is non-zero
-                        // - the only way to get zero from an addition without overflow is for both
-                        //   sides to be zero
-                        //
-                        // So the result cannot be zero.
-                        Some(unsafe { $Ty::new_unchecked(result) })
-                    } else {
-                        None
-                    }
-                }
+        /// 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.
+        ///
+        ///
+        /// # Examples
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let one = ", stringify!($Ty), "::new(1)?;")]
+        #[doc = concat!("let two = ", stringify!($Ty), "::new(2)?;")]
+        #[doc = concat!("let max = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MAX)?;")]
+        ///
+        /// assert_eq!(Some(two), one.checked_add(1));
+        /// assert_eq!(None, max.checked_add(1));
+        /// # Some(())
+        /// # }
+        /// ```
+        #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
+        #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
+        #[must_use = "this returns the result of the operation, \
+                      without modifying the original"]
+        #[inline]
+        pub const fn checked_add(self, other: $Int) -> Option<$Ty> {
+            if let Some(result) = self.get().checked_add(other) {
+                // SAFETY:
+                // - `checked_add` returns `None` on overflow
+                // - `self` is non-zero
+                // - the only way to get zero from an addition without overflow is for both
+                //   sides to be zero
+                //
+                // So the result cannot be zero.
+                Some(unsafe { $Ty::new_unchecked(result) })
+            } else {
+                None
+            }
+        }
 
-                /// Adds an unsigned integer to a non-zero value.
-                #[doc = concat!("Return [`", stringify!($Ty), "::MAX`] on overflow.")]
-                ///
-                /// # Examples
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let one = ", stringify!($Ty), "::new(1)?;")]
-                #[doc = concat!("let two = ", stringify!($Ty), "::new(2)?;")]
-                #[doc = concat!("let max = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MAX)?;")]
-                ///
-                /// assert_eq!(two, one.saturating_add(1));
-                /// assert_eq!(max, max.saturating_add(1));
-                /// # Some(())
-                /// # }
-                /// ```
-                #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
-                #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
-                #[must_use = "this returns the result of the operation, \
-                              without modifying the original"]
-                #[inline]
-                pub const fn saturating_add(self, other: $Int) -> $Ty {
-                    // SAFETY:
-                    // - `saturating_add` returns `u*::MAX` on overflow, which is non-zero
-                    // - `self` is non-zero
-                    // - the only way to get zero from an addition without overflow is for both
-                    //   sides to be zero
-                    //
-                    // So the result cannot be zero.
-                    unsafe { $Ty::new_unchecked(self.get().saturating_add(other)) }
-                }
+        /// Adds an unsigned integer to a non-zero value.
+        #[doc = concat!("Return [`", stringify!($Ty), "::MAX`] on overflow.")]
+        ///
+        /// # Examples
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let one = ", stringify!($Ty), "::new(1)?;")]
+        #[doc = concat!("let two = ", stringify!($Ty), "::new(2)?;")]
+        #[doc = concat!("let max = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MAX)?;")]
+        ///
+        /// assert_eq!(two, one.saturating_add(1));
+        /// assert_eq!(max, max.saturating_add(1));
+        /// # Some(())
+        /// # }
+        /// ```
+        #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
+        #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
+        #[must_use = "this returns the result of the operation, \
+                      without modifying the original"]
+        #[inline]
+        pub const fn saturating_add(self, other: $Int) -> $Ty {
+            // SAFETY:
+            // - `saturating_add` returns `u*::MAX` on overflow, which is non-zero
+            // - `self` is non-zero
+            // - the only way to get zero from an addition without overflow is for both
+            //   sides to be zero
+            //
+            // So the result cannot be zero.
+            unsafe { $Ty::new_unchecked(self.get().saturating_add(other)) }
+        }
 
-                /// Adds an unsigned integer to a non-zero value,
-                /// assuming overflow cannot occur.
-                /// Overflow is unchecked, and it is undefined behaviour to overflow
-                /// *even if the result would wrap to a non-zero value*.
-                /// The behaviour is undefined as soon as
-                #[doc = concat!("`self + rhs > ", stringify!($Int), "::MAX`.")]
-                ///
-                /// # Examples
-                ///
-                /// ```
-                /// #![feature(nonzero_ops)]
-                ///
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let one = ", stringify!($Ty), "::new(1)?;")]
-                #[doc = concat!("let two = ", stringify!($Ty), "::new(2)?;")]
-                ///
-                /// assert_eq!(two, unsafe { one.unchecked_add(1) });
-                /// # Some(())
-                /// # }
-                /// ```
-                #[unstable(feature = "nonzero_ops", issue = "84186")]
-                #[must_use = "this returns the result of the operation, \
-                              without modifying the original"]
-                #[inline]
-                pub const unsafe fn unchecked_add(self, other: $Int) -> $Ty {
-                    // SAFETY: The caller ensures there is no overflow.
-                    unsafe { $Ty::new_unchecked(self.get().unchecked_add(other)) }
-                }
+        /// Adds an unsigned integer to a non-zero value,
+        /// assuming overflow cannot occur.
+        /// Overflow is unchecked, and it is undefined behaviour to overflow
+        /// *even if the result would wrap to a non-zero value*.
+        /// The behaviour is undefined as soon as
+        #[doc = concat!("`self + rhs > ", stringify!($Int), "::MAX`.")]
+        ///
+        /// # Examples
+        ///
+        /// ```
+        /// #![feature(nonzero_ops)]
+        ///
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let one = ", stringify!($Ty), "::new(1)?;")]
+        #[doc = concat!("let two = ", stringify!($Ty), "::new(2)?;")]
+        ///
+        /// assert_eq!(two, unsafe { one.unchecked_add(1) });
+        /// # Some(())
+        /// # }
+        /// ```
+        #[unstable(feature = "nonzero_ops", issue = "84186")]
+        #[must_use = "this returns the result of the operation, \
+                      without modifying the original"]
+        #[inline]
+        pub const unsafe fn unchecked_add(self, other: $Int) -> $Ty {
+            // SAFETY: The caller ensures there is no overflow.
+            unsafe { $Ty::new_unchecked(self.get().unchecked_add(other)) }
+        }
 
-                /// Returns the smallest power of two greater than or equal to n.
-                /// Checks for overflow and returns [`None`]
-                /// if the next power of two is greater than the type’s maximum value.
-                /// As a consequence, the result cannot wrap to zero.
-                ///
-                /// # Examples
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let two = ", stringify!($Ty), "::new(2)?;")]
-                #[doc = concat!("let three = ", stringify!($Ty), "::new(3)?;")]
-                #[doc = concat!("let four = ", stringify!($Ty), "::new(4)?;")]
-                #[doc = concat!("let max = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MAX)?;")]
-                ///
-                /// assert_eq!(Some(two), two.checked_next_power_of_two() );
-                /// assert_eq!(Some(four), three.checked_next_power_of_two() );
-                /// assert_eq!(None, max.checked_next_power_of_two() );
-                /// # Some(())
-                /// # }
-                /// ```
-                #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
-                #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
-                #[must_use = "this returns the result of the operation, \
-                              without modifying the original"]
-                #[inline]
-                pub const fn checked_next_power_of_two(self) -> Option<$Ty> {
-                    if let Some(nz) = self.get().checked_next_power_of_two() {
-                        // SAFETY: The next power of two is positive
-                        // and overflow is checked.
-                        Some(unsafe { $Ty::new_unchecked(nz) })
-                    } else {
-                        None
-                    }
-                }
+        /// Returns the smallest power of two greater than or equal to n.
+        /// Checks for overflow and returns [`None`]
+        /// if the next power of two is greater than the type’s maximum value.
+        /// As a consequence, the result cannot wrap to zero.
+        ///
+        /// # Examples
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let two = ", stringify!($Ty), "::new(2)?;")]
+        #[doc = concat!("let three = ", stringify!($Ty), "::new(3)?;")]
+        #[doc = concat!("let four = ", stringify!($Ty), "::new(4)?;")]
+        #[doc = concat!("let max = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MAX)?;")]
+        ///
+        /// assert_eq!(Some(two), two.checked_next_power_of_two() );
+        /// assert_eq!(Some(four), three.checked_next_power_of_two() );
+        /// assert_eq!(None, max.checked_next_power_of_two() );
+        /// # Some(())
+        /// # }
+        /// ```
+        #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
+        #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
+        #[must_use = "this returns the result of the operation, \
+                      without modifying the original"]
+        #[inline]
+        pub const fn checked_next_power_of_two(self) -> Option<$Ty> {
+            if let Some(nz) = self.get().checked_next_power_of_two() {
+                // SAFETY: The next power of two is positive
+                // and overflow is checked.
+                Some(unsafe { $Ty::new_unchecked(nz) })
+            } else {
+                None
+            }
+        }
 
-                /// Returns the base 2 logarithm of the number, rounded down.
-                ///
-                /// This is the same operation as
-                #[doc = concat!("[`", stringify!($Int), "::ilog2`],")]
-                /// except that it has no failure cases to worry about
-                /// since this value can never be zero.
-                ///
-                /// # Examples
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                #[doc = concat!("assert_eq!(", stringify!($Ty), "::new(7).unwrap().ilog2(), 2);")]
-                #[doc = concat!("assert_eq!(", stringify!($Ty), "::new(8).unwrap().ilog2(), 3);")]
-                #[doc = concat!("assert_eq!(", stringify!($Ty), "::new(9).unwrap().ilog2(), 3);")]
-                /// ```
-                #[stable(feature = "int_log", since = "1.67.0")]
-                #[rustc_const_stable(feature = "int_log", since = "1.67.0")]
-                #[must_use = "this returns the result of the operation, \
-                              without modifying the original"]
-                #[inline]
-                pub const fn ilog2(self) -> u32 {
-                    Self::BITS - 1 - self.leading_zeros()
-                }
+        /// Returns the base 2 logarithm of the number, rounded down.
+        ///
+        /// This is the same operation as
+        #[doc = concat!("[`", stringify!($Int), "::ilog2`],")]
+        /// except that it has no failure cases to worry about
+        /// since this value can never be zero.
+        ///
+        /// # Examples
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        #[doc = concat!("assert_eq!(", stringify!($Ty), "::new(7).unwrap().ilog2(), 2);")]
+        #[doc = concat!("assert_eq!(", stringify!($Ty), "::new(8).unwrap().ilog2(), 3);")]
+        #[doc = concat!("assert_eq!(", stringify!($Ty), "::new(9).unwrap().ilog2(), 3);")]
+        /// ```
+        #[stable(feature = "int_log", since = "1.67.0")]
+        #[rustc_const_stable(feature = "int_log", since = "1.67.0")]
+        #[must_use = "this returns the result of the operation, \
+                      without modifying the original"]
+        #[inline]
+        pub const fn ilog2(self) -> u32 {
+            Self::BITS - 1 - self.leading_zeros()
+        }
 
-                /// Returns the base 10 logarithm of the number, rounded down.
-                ///
-                /// This is the same operation as
-                #[doc = concat!("[`", stringify!($Int), "::ilog10`],")]
-                /// except that it has no failure cases to worry about
-                /// since this value can never be zero.
-                ///
-                /// # Examples
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                #[doc = concat!("assert_eq!(", stringify!($Ty), "::new(99).unwrap().ilog10(), 1);")]
-                #[doc = concat!("assert_eq!(", stringify!($Ty), "::new(100).unwrap().ilog10(), 2);")]
-                #[doc = concat!("assert_eq!(", stringify!($Ty), "::new(101).unwrap().ilog10(), 2);")]
-                /// ```
-                #[stable(feature = "int_log", since = "1.67.0")]
-                #[rustc_const_stable(feature = "int_log", since = "1.67.0")]
-                #[must_use = "this returns the result of the operation, \
-                              without modifying the original"]
-                #[inline]
-                pub const fn ilog10(self) -> u32 {
-                    super::int_log10::$Int(self.get())
-                }
+        /// Returns the base 10 logarithm of the number, rounded down.
+        ///
+        /// This is the same operation as
+        #[doc = concat!("[`", stringify!($Int), "::ilog10`],")]
+        /// except that it has no failure cases to worry about
+        /// since this value can never be zero.
+        ///
+        /// # Examples
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        #[doc = concat!("assert_eq!(", stringify!($Ty), "::new(99).unwrap().ilog10(), 1);")]
+        #[doc = concat!("assert_eq!(", stringify!($Ty), "::new(100).unwrap().ilog10(), 2);")]
+        #[doc = concat!("assert_eq!(", stringify!($Ty), "::new(101).unwrap().ilog10(), 2);")]
+        /// ```
+        #[stable(feature = "int_log", since = "1.67.0")]
+        #[rustc_const_stable(feature = "int_log", since = "1.67.0")]
+        #[must_use = "this returns the result of the operation, \
+                      without modifying the original"]
+        #[inline]
+        pub const fn ilog10(self) -> u32 {
+            super::int_log10::$Int(self.get())
+        }
 
-                /// Calculates the middle point of `self` and `rhs`.
-                ///
-                /// `midpoint(a, b)` is `(a + b) >> 1` as if it were performed in a
-                /// sufficiently-large signed integral type. This implies that the result is
-                /// always rounded towards negative infinity and that no overflow will ever occur.
-                ///
-                /// # Examples
-                ///
-                /// ```
-                /// #![feature(num_midpoint)]
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                ///
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let one = ", stringify!($Ty), "::new(1)?;")]
-                #[doc = concat!("let two = ", stringify!($Ty), "::new(2)?;")]
-                #[doc = concat!("let four = ", stringify!($Ty), "::new(4)?;")]
-                ///
-                /// assert_eq!(one.midpoint(four), two);
-                /// assert_eq!(four.midpoint(one), two);
-                /// # Some(())
-                /// # }
-                /// ```
-                #[unstable(feature = "num_midpoint", issue = "110840")]
-                #[rustc_const_unstable(feature = "const_num_midpoint", issue = "110840")]
-                #[rustc_allow_const_fn_unstable(const_num_midpoint)]
-                #[must_use = "this returns the result of the operation, \
-                              without modifying the original"]
-                #[inline]
-                pub const fn midpoint(self, rhs: Self) -> Self {
-                    // SAFETY: The only way to get `0` with midpoint is to have two opposite or
-                    // near opposite numbers: (-5, 5), (0, 1), (0, 0) which is impossible because
-                    // of the unsignedness of this number and also because $Ty is guaranteed to
-                    // never being 0.
-                    unsafe { $Ty::new_unchecked(self.get().midpoint(rhs.get())) }
-                }
+        /// Calculates the middle point of `self` and `rhs`.
+        ///
+        /// `midpoint(a, b)` is `(a + b) >> 1` as if it were performed in a
+        /// sufficiently-large signed integral type. This implies that the result is
+        /// always rounded towards negative infinity and that no overflow will ever occur.
+        ///
+        /// # Examples
+        ///
+        /// ```
+        /// #![feature(num_midpoint)]
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        ///
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let one = ", stringify!($Ty), "::new(1)?;")]
+        #[doc = concat!("let two = ", stringify!($Ty), "::new(2)?;")]
+        #[doc = concat!("let four = ", stringify!($Ty), "::new(4)?;")]
+        ///
+        /// assert_eq!(one.midpoint(four), two);
+        /// assert_eq!(four.midpoint(one), two);
+        /// # Some(())
+        /// # }
+        /// ```
+        #[unstable(feature = "num_midpoint", issue = "110840")]
+        #[rustc_const_unstable(feature = "const_num_midpoint", issue = "110840")]
+        #[rustc_allow_const_fn_unstable(const_num_midpoint)]
+        #[must_use = "this returns the result of the operation, \
+                      without modifying the original"]
+        #[inline]
+        pub const fn midpoint(self, rhs: Self) -> Self {
+            // SAFETY: The only way to get `0` with midpoint is to have two opposite or
+            // near opposite numbers: (-5, 5), (0, 1), (0, 0) which is impossible because
+            // of the unsignedness of this number and also because $Ty is guaranteed to
+            // never being 0.
+            unsafe { $Ty::new_unchecked(self.get().midpoint(rhs.get())) }
+        }
     };
 
     // Methods for signed nonzero types only.
@@ -557,383 +557,383 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
         UnsignedNonZero = $Uty:ident,
         UnsignedPrimitive = $Uint:ty,
     ) => {
-                /// Computes the absolute value of self.
-                #[doc = concat!("See [`", stringify!($Int), "::abs`]")]
-                /// for documentation on overflow behaviour.
-                ///
-                /// # Example
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let pos = ", stringify!($Ty), "::new(1)?;")]
-                #[doc = concat!("let neg = ", stringify!($Ty), "::new(-1)?;")]
-                ///
-                /// assert_eq!(pos, pos.abs());
-                /// assert_eq!(pos, neg.abs());
-                /// # Some(())
-                /// # }
-                /// ```
-                #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
-                #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
-                #[must_use = "this returns the result of the operation, \
-                              without modifying the original"]
-                #[inline]
-                pub const fn abs(self) -> $Ty {
-                    // SAFETY: This cannot overflow to zero.
-                    unsafe { $Ty::new_unchecked(self.get().abs()) }
-                }
+        /// Computes the absolute value of self.
+        #[doc = concat!("See [`", stringify!($Int), "::abs`]")]
+        /// for documentation on overflow behaviour.
+        ///
+        /// # Example
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let pos = ", stringify!($Ty), "::new(1)?;")]
+        #[doc = concat!("let neg = ", stringify!($Ty), "::new(-1)?;")]
+        ///
+        /// assert_eq!(pos, pos.abs());
+        /// assert_eq!(pos, neg.abs());
+        /// # Some(())
+        /// # }
+        /// ```
+        #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
+        #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
+        #[must_use = "this returns the result of the operation, \
+                      without modifying the original"]
+        #[inline]
+        pub const fn abs(self) -> $Ty {
+            // SAFETY: This cannot overflow to zero.
+            unsafe { $Ty::new_unchecked(self.get().abs()) }
+        }
 
-                /// Checked absolute value.
-                /// Checks for overflow and returns [`None`] if
-                #[doc = concat!("`self == ", stringify!($Ty), "::MIN`.")]
-                /// The result cannot be zero.
-                ///
-                /// # Example
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let pos = ", stringify!($Ty), "::new(1)?;")]
-                #[doc = concat!("let neg = ", stringify!($Ty), "::new(-1)?;")]
-                #[doc = concat!("let min = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MIN)?;")]
-                ///
-                /// assert_eq!(Some(pos), neg.checked_abs());
-                /// assert_eq!(None, min.checked_abs());
-                /// # Some(())
-                /// # }
-                /// ```
-                #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
-                #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
-                #[must_use = "this returns the result of the operation, \
-                              without modifying the original"]
-                #[inline]
-                pub const fn checked_abs(self) -> Option<$Ty> {
-                    if let Some(nz) = self.get().checked_abs() {
-                        // SAFETY: absolute value of nonzero cannot yield zero values.
-                        Some(unsafe { $Ty::new_unchecked(nz) })
-                    } else {
-                        None
-                    }
-                }
+        /// Checked absolute value.
+        /// Checks for overflow and returns [`None`] if
+        #[doc = concat!("`self == ", stringify!($Ty), "::MIN`.")]
+        /// The result cannot be zero.
+        ///
+        /// # Example
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let pos = ", stringify!($Ty), "::new(1)?;")]
+        #[doc = concat!("let neg = ", stringify!($Ty), "::new(-1)?;")]
+        #[doc = concat!("let min = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MIN)?;")]
+        ///
+        /// assert_eq!(Some(pos), neg.checked_abs());
+        /// assert_eq!(None, min.checked_abs());
+        /// # Some(())
+        /// # }
+        /// ```
+        #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
+        #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
+        #[must_use = "this returns the result of the operation, \
+                      without modifying the original"]
+        #[inline]
+        pub const fn checked_abs(self) -> Option<$Ty> {
+            if let Some(nz) = self.get().checked_abs() {
+                // SAFETY: absolute value of nonzero cannot yield zero values.
+                Some(unsafe { $Ty::new_unchecked(nz) })
+            } else {
+                None
+            }
+        }
 
-                /// Computes the absolute value of self,
-                /// with overflow information, see
-                #[doc = concat!("[`", stringify!($Int), "::overflowing_abs`].")]
-                ///
-                /// # Example
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let pos = ", stringify!($Ty), "::new(1)?;")]
-                #[doc = concat!("let neg = ", stringify!($Ty), "::new(-1)?;")]
-                #[doc = concat!("let min = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MIN)?;")]
-                ///
-                /// assert_eq!((pos, false), pos.overflowing_abs());
-                /// assert_eq!((pos, false), neg.overflowing_abs());
-                /// assert_eq!((min, true), min.overflowing_abs());
-                /// # Some(())
-                /// # }
-                /// ```
-                #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
-                #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
-                #[must_use = "this returns the result of the operation, \
-                              without modifying the original"]
-                #[inline]
-                pub const fn overflowing_abs(self) -> ($Ty, bool) {
-                    let (nz, flag) = self.get().overflowing_abs();
-                    (
-                        // SAFETY: absolute value of nonzero cannot yield zero values.
-                        unsafe { $Ty::new_unchecked(nz) },
-                        flag,
-                    )
-                }
+        /// Computes the absolute value of self,
+        /// with overflow information, see
+        #[doc = concat!("[`", stringify!($Int), "::overflowing_abs`].")]
+        ///
+        /// # Example
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let pos = ", stringify!($Ty), "::new(1)?;")]
+        #[doc = concat!("let neg = ", stringify!($Ty), "::new(-1)?;")]
+        #[doc = concat!("let min = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MIN)?;")]
+        ///
+        /// assert_eq!((pos, false), pos.overflowing_abs());
+        /// assert_eq!((pos, false), neg.overflowing_abs());
+        /// assert_eq!((min, true), min.overflowing_abs());
+        /// # Some(())
+        /// # }
+        /// ```
+        #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
+        #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
+        #[must_use = "this returns the result of the operation, \
+                      without modifying the original"]
+        #[inline]
+        pub const fn overflowing_abs(self) -> ($Ty, bool) {
+            let (nz, flag) = self.get().overflowing_abs();
+            (
+                // SAFETY: absolute value of nonzero cannot yield zero values.
+                unsafe { $Ty::new_unchecked(nz) },
+                flag,
+            )
+        }
 
-                /// Saturating absolute value, see
-                #[doc = concat!("[`", stringify!($Int), "::saturating_abs`].")]
-                ///
-                /// # Example
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let pos = ", stringify!($Ty), "::new(1)?;")]
-                #[doc = concat!("let neg = ", stringify!($Ty), "::new(-1)?;")]
-                #[doc = concat!("let min = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MIN)?;")]
-                #[doc = concat!("let min_plus = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MIN + 1)?;")]
-                #[doc = concat!("let max = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MAX)?;")]
-                ///
-                /// assert_eq!(pos, pos.saturating_abs());
-                /// assert_eq!(pos, neg.saturating_abs());
-                /// assert_eq!(max, min.saturating_abs());
-                /// assert_eq!(max, min_plus.saturating_abs());
-                /// # Some(())
-                /// # }
-                /// ```
-                #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
-                #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
-                #[must_use = "this returns the result of the operation, \
-                              without modifying the original"]
-                #[inline]
-                pub const fn saturating_abs(self) -> $Ty {
-                    // SAFETY: absolute value of nonzero cannot yield zero values.
-                    unsafe { $Ty::new_unchecked(self.get().saturating_abs()) }
-                }
+        /// Saturating absolute value, see
+        #[doc = concat!("[`", stringify!($Int), "::saturating_abs`].")]
+        ///
+        /// # Example
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let pos = ", stringify!($Ty), "::new(1)?;")]
+        #[doc = concat!("let neg = ", stringify!($Ty), "::new(-1)?;")]
+        #[doc = concat!("let min = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MIN)?;")]
+        #[doc = concat!("let min_plus = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MIN + 1)?;")]
+        #[doc = concat!("let max = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MAX)?;")]
+        ///
+        /// assert_eq!(pos, pos.saturating_abs());
+        /// assert_eq!(pos, neg.saturating_abs());
+        /// assert_eq!(max, min.saturating_abs());
+        /// assert_eq!(max, min_plus.saturating_abs());
+        /// # Some(())
+        /// # }
+        /// ```
+        #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
+        #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
+        #[must_use = "this returns the result of the operation, \
+                      without modifying the original"]
+        #[inline]
+        pub const fn saturating_abs(self) -> $Ty {
+            // SAFETY: absolute value of nonzero cannot yield zero values.
+            unsafe { $Ty::new_unchecked(self.get().saturating_abs()) }
+        }
 
-                /// Wrapping absolute value, see
-                #[doc = concat!("[`", stringify!($Int), "::wrapping_abs`].")]
-                ///
-                /// # Example
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let pos = ", stringify!($Ty), "::new(1)?;")]
-                #[doc = concat!("let neg = ", stringify!($Ty), "::new(-1)?;")]
-                #[doc = concat!("let min = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MIN)?;")]
-                #[doc = concat!("# let max = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MAX)?;")]
-                ///
-                /// assert_eq!(pos, pos.wrapping_abs());
-                /// assert_eq!(pos, neg.wrapping_abs());
-                /// assert_eq!(min, min.wrapping_abs());
-                /// assert_eq!(max, (-max).wrapping_abs());
-                /// # Some(())
-                /// # }
-                /// ```
-                #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
-                #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
-                #[must_use = "this returns the result of the operation, \
-                              without modifying the original"]
-                #[inline]
-                pub const fn wrapping_abs(self) -> $Ty {
-                    // SAFETY: absolute value of nonzero cannot yield zero values.
-                    unsafe { $Ty::new_unchecked(self.get().wrapping_abs()) }
-                }
+        /// Wrapping absolute value, see
+        #[doc = concat!("[`", stringify!($Int), "::wrapping_abs`].")]
+        ///
+        /// # Example
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let pos = ", stringify!($Ty), "::new(1)?;")]
+        #[doc = concat!("let neg = ", stringify!($Ty), "::new(-1)?;")]
+        #[doc = concat!("let min = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MIN)?;")]
+        #[doc = concat!("# let max = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MAX)?;")]
+        ///
+        /// assert_eq!(pos, pos.wrapping_abs());
+        /// assert_eq!(pos, neg.wrapping_abs());
+        /// assert_eq!(min, min.wrapping_abs());
+        /// assert_eq!(max, (-max).wrapping_abs());
+        /// # Some(())
+        /// # }
+        /// ```
+        #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
+        #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
+        #[must_use = "this returns the result of the operation, \
+                      without modifying the original"]
+        #[inline]
+        pub const fn wrapping_abs(self) -> $Ty {
+            // SAFETY: absolute value of nonzero cannot yield zero values.
+            unsafe { $Ty::new_unchecked(self.get().wrapping_abs()) }
+        }
 
-                /// Computes the absolute value of self
-                /// without any wrapping or panicking.
-                ///
-                /// # Example
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                #[doc = concat!("# use std::num::", stringify!($Uty), ";")]
-                ///
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let u_pos = ", stringify!($Uty), "::new(1)?;")]
-                #[doc = concat!("let i_pos = ", stringify!($Ty), "::new(1)?;")]
-                #[doc = concat!("let i_neg = ", stringify!($Ty), "::new(-1)?;")]
-                #[doc = concat!("let i_min = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MIN)?;")]
-                #[doc = concat!("let u_max = ", stringify!($Uty), "::new(",
-                                stringify!($Uint), "::MAX / 2 + 1)?;")]
-                ///
-                /// assert_eq!(u_pos, i_pos.unsigned_abs());
-                /// assert_eq!(u_pos, i_neg.unsigned_abs());
-                /// assert_eq!(u_max, i_min.unsigned_abs());
-                /// # Some(())
-                /// # }
-                /// ```
-                #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
-                #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
-                #[must_use = "this returns the result of the operation, \
-                              without modifying the original"]
-                #[inline]
-                pub const fn unsigned_abs(self) -> $Uty {
-                    // SAFETY: absolute value of nonzero cannot yield zero values.
-                    unsafe { $Uty::new_unchecked(self.get().unsigned_abs()) }
-                }
+        /// Computes the absolute value of self
+        /// without any wrapping or panicking.
+        ///
+        /// # Example
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        #[doc = concat!("# use std::num::", stringify!($Uty), ";")]
+        ///
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let u_pos = ", stringify!($Uty), "::new(1)?;")]
+        #[doc = concat!("let i_pos = ", stringify!($Ty), "::new(1)?;")]
+        #[doc = concat!("let i_neg = ", stringify!($Ty), "::new(-1)?;")]
+        #[doc = concat!("let i_min = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MIN)?;")]
+        #[doc = concat!("let u_max = ", stringify!($Uty), "::new(",
+                        stringify!($Uint), "::MAX / 2 + 1)?;")]
+        ///
+        /// assert_eq!(u_pos, i_pos.unsigned_abs());
+        /// assert_eq!(u_pos, i_neg.unsigned_abs());
+        /// assert_eq!(u_max, i_min.unsigned_abs());
+        /// # Some(())
+        /// # }
+        /// ```
+        #[stable(feature = "nonzero_checked_ops", since = "1.64.0")]
+        #[rustc_const_stable(feature = "const_nonzero_checked_ops", since = "1.64.0")]
+        #[must_use = "this returns the result of the operation, \
+                      without modifying the original"]
+        #[inline]
+        pub const fn unsigned_abs(self) -> $Uty {
+            // SAFETY: absolute value of nonzero cannot yield zero values.
+            unsafe { $Uty::new_unchecked(self.get().unsigned_abs()) }
+        }
 
-                /// Returns `true` if `self` is positive and `false` if the
-                /// number is negative.
-                ///
-                /// # Example
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let pos_five = ", stringify!($Ty), "::new(5)?;")]
-                #[doc = concat!("let neg_five = ", stringify!($Ty), "::new(-5)?;")]
-                ///
-                /// assert!(pos_five.is_positive());
-                /// assert!(!neg_five.is_positive());
-                /// # Some(())
-                /// # }
-                /// ```
-                #[must_use]
-                #[inline]
-                #[stable(feature = "nonzero_negation_ops", since = "1.71.0")]
-                #[rustc_const_stable(feature = "nonzero_negation_ops", since = "1.71.0")]
-                pub const fn is_positive(self) -> bool {
-                    self.get().is_positive()
-                }
+        /// Returns `true` if `self` is positive and `false` if the
+        /// number is negative.
+        ///
+        /// # Example
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let pos_five = ", stringify!($Ty), "::new(5)?;")]
+        #[doc = concat!("let neg_five = ", stringify!($Ty), "::new(-5)?;")]
+        ///
+        /// assert!(pos_five.is_positive());
+        /// assert!(!neg_five.is_positive());
+        /// # Some(())
+        /// # }
+        /// ```
+        #[must_use]
+        #[inline]
+        #[stable(feature = "nonzero_negation_ops", since = "1.71.0")]
+        #[rustc_const_stable(feature = "nonzero_negation_ops", since = "1.71.0")]
+        pub const fn is_positive(self) -> bool {
+            self.get().is_positive()
+        }
 
-                /// Returns `true` if `self` is negative and `false` if the
-                /// number is positive.
-                ///
-                /// # Example
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let pos_five = ", stringify!($Ty), "::new(5)?;")]
-                #[doc = concat!("let neg_five = ", stringify!($Ty), "::new(-5)?;")]
-                ///
-                /// assert!(neg_five.is_negative());
-                /// assert!(!pos_five.is_negative());
-                /// # Some(())
-                /// # }
-                /// ```
-                #[must_use]
-                #[inline]
-                #[stable(feature = "nonzero_negation_ops", since = "1.71.0")]
-                #[rustc_const_stable(feature = "nonzero_negation_ops", since = "1.71.0")]
-                pub const fn is_negative(self) -> bool {
-                    self.get().is_negative()
-                }
+        /// Returns `true` if `self` is negative and `false` if the
+        /// number is positive.
+        ///
+        /// # Example
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let pos_five = ", stringify!($Ty), "::new(5)?;")]
+        #[doc = concat!("let neg_five = ", stringify!($Ty), "::new(-5)?;")]
+        ///
+        /// assert!(neg_five.is_negative());
+        /// assert!(!pos_five.is_negative());
+        /// # Some(())
+        /// # }
+        /// ```
+        #[must_use]
+        #[inline]
+        #[stable(feature = "nonzero_negation_ops", since = "1.71.0")]
+        #[rustc_const_stable(feature = "nonzero_negation_ops", since = "1.71.0")]
+        pub const fn is_negative(self) -> bool {
+            self.get().is_negative()
+        }
 
-                /// Checked negation. Computes `-self`,
-                #[doc = concat!("returning `None` if `self == ", stringify!($Ty), "::MIN`.")]
-                ///
-                /// # Example
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let pos_five = ", stringify!($Ty), "::new(5)?;")]
-                #[doc = concat!("let neg_five = ", stringify!($Ty), "::new(-5)?;")]
-                #[doc = concat!("let min = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MIN)?;")]
-                ///
-                /// assert_eq!(pos_five.checked_neg(), Some(neg_five));
-                /// assert_eq!(min.checked_neg(), None);
-                /// # Some(())
-                /// # }
-                /// ```
-                #[inline]
-                #[stable(feature = "nonzero_negation_ops", since = "1.71.0")]
-                #[rustc_const_stable(feature = "nonzero_negation_ops", since = "1.71.0")]
-                pub const fn checked_neg(self) -> Option<$Ty> {
-                    if let Some(result) = self.get().checked_neg() {
-                        // SAFETY: negation of nonzero cannot yield zero values.
-                        return Some(unsafe { $Ty::new_unchecked(result) });
-                    }
-                    None
-                }
+        /// Checked negation. Computes `-self`,
+        #[doc = concat!("returning `None` if `self == ", stringify!($Ty), "::MIN`.")]
+        ///
+        /// # Example
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let pos_five = ", stringify!($Ty), "::new(5)?;")]
+        #[doc = concat!("let neg_five = ", stringify!($Ty), "::new(-5)?;")]
+        #[doc = concat!("let min = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MIN)?;")]
+        ///
+        /// assert_eq!(pos_five.checked_neg(), Some(neg_five));
+        /// assert_eq!(min.checked_neg(), None);
+        /// # Some(())
+        /// # }
+        /// ```
+        #[inline]
+        #[stable(feature = "nonzero_negation_ops", since = "1.71.0")]
+        #[rustc_const_stable(feature = "nonzero_negation_ops", since = "1.71.0")]
+        pub const fn checked_neg(self) -> Option<$Ty> {
+            if let Some(result) = self.get().checked_neg() {
+                // SAFETY: negation of nonzero cannot yield zero values.
+                return Some(unsafe { $Ty::new_unchecked(result) });
+            }
+            None
+        }
 
-                /// Negates self, overflowing if this is equal to the minimum value.
-                ///
-                #[doc = concat!("See [`", stringify!($Int), "::overflowing_neg`]")]
-                /// for documentation on overflow behaviour.
-                ///
-                /// # Example
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let pos_five = ", stringify!($Ty), "::new(5)?;")]
-                #[doc = concat!("let neg_five = ", stringify!($Ty), "::new(-5)?;")]
-                #[doc = concat!("let min = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MIN)?;")]
-                ///
-                /// assert_eq!(pos_five.overflowing_neg(), (neg_five, false));
-                /// assert_eq!(min.overflowing_neg(), (min, true));
-                /// # Some(())
-                /// # }
-                /// ```
-                #[inline]
-                #[stable(feature = "nonzero_negation_ops", since = "1.71.0")]
-                #[rustc_const_stable(feature = "nonzero_negation_ops", since = "1.71.0")]
-                pub const fn overflowing_neg(self) -> ($Ty, bool) {
-                    let (result, overflow) = self.get().overflowing_neg();
-                    // SAFETY: negation of nonzero cannot yield zero values.
-                    ((unsafe { $Ty::new_unchecked(result) }), overflow)
-                }
+        /// Negates self, overflowing if this is equal to the minimum value.
+        ///
+        #[doc = concat!("See [`", stringify!($Int), "::overflowing_neg`]")]
+        /// for documentation on overflow behaviour.
+        ///
+        /// # Example
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let pos_five = ", stringify!($Ty), "::new(5)?;")]
+        #[doc = concat!("let neg_five = ", stringify!($Ty), "::new(-5)?;")]
+        #[doc = concat!("let min = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MIN)?;")]
+        ///
+        /// assert_eq!(pos_five.overflowing_neg(), (neg_five, false));
+        /// assert_eq!(min.overflowing_neg(), (min, true));
+        /// # Some(())
+        /// # }
+        /// ```
+        #[inline]
+        #[stable(feature = "nonzero_negation_ops", since = "1.71.0")]
+        #[rustc_const_stable(feature = "nonzero_negation_ops", since = "1.71.0")]
+        pub const fn overflowing_neg(self) -> ($Ty, bool) {
+            let (result, overflow) = self.get().overflowing_neg();
+            // SAFETY: negation of nonzero cannot yield zero values.
+            ((unsafe { $Ty::new_unchecked(result) }), overflow)
+        }
 
-                /// Saturating negation. Computes `-self`,
-                #[doc = concat!("returning [`", stringify!($Ty), "::MAX`]")]
-                #[doc = concat!("if `self == ", stringify!($Ty), "::MIN`")]
-                /// instead of overflowing.
-                ///
-                /// # Example
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let pos_five = ", stringify!($Ty), "::new(5)?;")]
-                #[doc = concat!("let neg_five = ", stringify!($Ty), "::new(-5)?;")]
-                #[doc = concat!("let min = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MIN)?;")]
-                #[doc = concat!("let min_plus_one = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MIN + 1)?;")]
-                #[doc = concat!("let max = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MAX)?;")]
-                ///
-                /// assert_eq!(pos_five.saturating_neg(), neg_five);
-                /// assert_eq!(min.saturating_neg(), max);
-                /// assert_eq!(max.saturating_neg(), min_plus_one);
-                /// # Some(())
-                /// # }
-                /// ```
-                #[inline]
-                #[stable(feature = "nonzero_negation_ops", since = "1.71.0")]
-                #[rustc_const_stable(feature = "nonzero_negation_ops", since = "1.71.0")]
-                pub const fn saturating_neg(self) -> $Ty {
-                    if let Some(result) = self.checked_neg() {
-                        return result;
-                    }
-                    $Ty::MAX
-                }
+        /// Saturating negation. Computes `-self`,
+        #[doc = concat!("returning [`", stringify!($Ty), "::MAX`]")]
+        #[doc = concat!("if `self == ", stringify!($Ty), "::MIN`")]
+        /// instead of overflowing.
+        ///
+        /// # Example
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let pos_five = ", stringify!($Ty), "::new(5)?;")]
+        #[doc = concat!("let neg_five = ", stringify!($Ty), "::new(-5)?;")]
+        #[doc = concat!("let min = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MIN)?;")]
+        #[doc = concat!("let min_plus_one = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MIN + 1)?;")]
+        #[doc = concat!("let max = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MAX)?;")]
+        ///
+        /// assert_eq!(pos_five.saturating_neg(), neg_five);
+        /// assert_eq!(min.saturating_neg(), max);
+        /// assert_eq!(max.saturating_neg(), min_plus_one);
+        /// # Some(())
+        /// # }
+        /// ```
+        #[inline]
+        #[stable(feature = "nonzero_negation_ops", since = "1.71.0")]
+        #[rustc_const_stable(feature = "nonzero_negation_ops", since = "1.71.0")]
+        pub const fn saturating_neg(self) -> $Ty {
+            if let Some(result) = self.checked_neg() {
+                return result;
+            }
+            $Ty::MAX
+        }
 
-                /// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary
-                /// of the type.
-                ///
-                #[doc = concat!("See [`", stringify!($Int), "::wrapping_neg`]")]
-                /// for documentation on overflow behaviour.
-                ///
-                /// # Example
-                ///
-                /// ```
-                #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
-                /// # fn main() { test().unwrap(); }
-                /// # fn test() -> Option<()> {
-                #[doc = concat!("let pos_five = ", stringify!($Ty), "::new(5)?;")]
-                #[doc = concat!("let neg_five = ", stringify!($Ty), "::new(-5)?;")]
-                #[doc = concat!("let min = ", stringify!($Ty), "::new(",
-                                stringify!($Int), "::MIN)?;")]
-                ///
-                /// assert_eq!(pos_five.wrapping_neg(), neg_five);
-                /// assert_eq!(min.wrapping_neg(), min);
-                /// # Some(())
-                /// # }
-                /// ```
-                #[inline]
-                #[stable(feature = "nonzero_negation_ops", since = "1.71.0")]
-                #[rustc_const_stable(feature = "nonzero_negation_ops", since = "1.71.0")]
-                pub const fn wrapping_neg(self) -> $Ty {
-                    let result = self.get().wrapping_neg();
-                    // SAFETY: negation of nonzero cannot yield zero values.
-                    unsafe { $Ty::new_unchecked(result) }
-                }
+        /// Wrapping (modular) negation. Computes `-self`, wrapping around at the boundary
+        /// of the type.
+        ///
+        #[doc = concat!("See [`", stringify!($Int), "::wrapping_neg`]")]
+        /// for documentation on overflow behaviour.
+        ///
+        /// # Example
+        ///
+        /// ```
+        #[doc = concat!("# use std::num::", stringify!($Ty), ";")]
+        /// # fn main() { test().unwrap(); }
+        /// # fn test() -> Option<()> {
+        #[doc = concat!("let pos_five = ", stringify!($Ty), "::new(5)?;")]
+        #[doc = concat!("let neg_five = ", stringify!($Ty), "::new(-5)?;")]
+        #[doc = concat!("let min = ", stringify!($Ty), "::new(",
+                        stringify!($Int), "::MIN)?;")]
+        ///
+        /// assert_eq!(pos_five.wrapping_neg(), neg_five);
+        /// assert_eq!(min.wrapping_neg(), min);
+        /// # Some(())
+        /// # }
+        /// ```
+        #[inline]
+        #[stable(feature = "nonzero_negation_ops", since = "1.71.0")]
+        #[rustc_const_stable(feature = "nonzero_negation_ops", since = "1.71.0")]
+        pub const fn wrapping_neg(self) -> $Ty {
+            let result = self.get().wrapping_neg();
+            // SAFETY: negation of nonzero cannot yield zero values.
+            unsafe { $Ty::new_unchecked(result) }
+        }
     };
 }