about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-08-15 16:16:33 +1000
committerGitHub <noreply@github.com>2025-08-15 16:16:33 +1000
commit65e2a8b6d89b2160827bd3e91d7eb523c82084ad (patch)
tree1a723d254a6243b8b30e0d4e0032c1ed629cabc8
parentb955aa722e190689740e6379eee9684c324e8d1f (diff)
parent9c0cfd262f4c1197d9993a78ad0fbfc04a9c774c (diff)
Rollup merge of #144947 - tautschnig:remove-stray-checked_div-comment, r=Mark-Simulacrum
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 2c9a1196849..0afad09bdc6 100644
--- a/library/core/src/num/uint_macros.rs
+++ b/library/core/src/num/uint_macros.rs
@@ -1094,23 +1094,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",