From 6b8eae0d243258f616562395be0b4dd5d5f23acf Mon Sep 17 00:00:00 2001 From: Nicholas Thompson Date: Fri, 19 Jan 2024 15:27:26 -0500 Subject: [PATCH] Make `saturating_div` Docs Consistent with Others --- library/core/src/num/int_macros.rs | 9 ++++----- library/core/src/num/uint_macros.rs | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index a0e275412e7..4b7daa1aafd 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -1121,6 +1121,10 @@ macro_rules! int_impl { /// Saturating integer division. Computes `self / rhs`, saturating at the /// numeric bounds instead of overflowing. /// + /// # Panics + /// + /// This function will panic if `rhs` is 0. + /// /// # Examples /// /// Basic usage: @@ -1131,11 +1135,6 @@ macro_rules! int_impl { #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.saturating_div(-1), ", stringify!($SelfT), "::MAX);")] /// /// ``` - /// - /// ```should_panic - #[doc = concat!("let _ = 1", stringify!($SelfT), ".saturating_div(0);")] - /// - /// ``` #[stable(feature = "saturating_div", since = "1.58.0")] #[rustc_const_stable(feature = "saturating_div", since = "1.58.0")] #[must_use = "this returns the result of the operation, \ diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index ad084a5c330..4d9aff8287b 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -1123,6 +1123,10 @@ macro_rules! uint_impl { /// Saturating integer division. Computes `self / rhs`, saturating at the /// numeric bounds instead of overflowing. /// + /// # Panics + /// + /// This function will panic if `rhs` is 0. + /// /// # Examples /// /// Basic usage: @@ -1131,11 +1135,6 @@ macro_rules! uint_impl { #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".saturating_div(2), 2);")] /// /// ``` - /// - /// ```should_panic - #[doc = concat!("let _ = 1", stringify!($SelfT), ".saturating_div(0);")] - /// - /// ``` #[stable(feature = "saturating_div", since = "1.58.0")] #[rustc_const_stable(feature = "saturating_div", since = "1.58.0")] #[must_use = "this returns the result of the operation, \