about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Tautschnig <tautschn@amazon.com>2025-08-05 08:59:08 +0000
committerMichael Tautschnig <tautschn@amazon.com>2025-08-05 17:33:04 +0000
commit9c0cfd262f4c1197d9993a78ad0fbfc04a9c774c (patch)
tree88e8b0850f6823559c25e06e42f57791b01a79d1
parent213d946a384b46989f6fd9c8ae9c547b4e354455 (diff)
Fix description of unsigned `checked_exact_div`
Like its signed counterpart, this function does not panic. Also, fix the
examples to document how it returns Some/None.
-rw-r--r--library/core/src/num/uint_macros.rs18
1 files changed, 6 insertions, 12 deletions
diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs
index 584cd60fbe5..ac5cbcec0b1 100644
--- a/library/core/src/num/uint_macros.rs
+++ b/library/core/src/num/uint_macros.rs
@@ -1103,23 +1103,17 @@ macro_rules! uint_impl {
             self / rhs
         }
 
-        /// Checked integer division without remainder. Computes `self / rhs`.
-        ///
-        /// # Panics
-        ///
-        /// This function will panic  if `rhs == 0` or `self % rhs != 0`.
+        /// Checked integer division without remainder. Computes `self / rhs`,
+        /// returning `None` if `rhs == 0` or if `self % rhs != 0`.
         ///
         /// # Examples
         ///
         /// ```
         /// #![feature(exact_div)]
-        #[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(2), 32);")]
-        #[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(32), 2);")]
-        /// ```
-        ///
-        /// ```should_panic
-        /// #![feature(exact_div)]
-        #[doc = concat!("let _ = 65", stringify!($SelfT), ".exact_div(2);")]
+        #[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_exact_div(2), Some(32));")]
+        #[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_exact_div(32), Some(2));")]
+        #[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_exact_div(0), None);")]
+        #[doc = concat!("assert_eq!(65", stringify!($SelfT), ".checked_exact_div(2), None);")]
         /// ```
         #[unstable(
             feature = "exact_div",