Skip to content

Commit 65e2a8b

Browse files
authored
Rollup merge of rust-lang#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.
2 parents b955aa7 + 9c0cfd2 commit 65e2a8b

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

library/core/src/num/uint_macros.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,23 +1094,17 @@ macro_rules! uint_impl {
10941094
self / rhs
10951095
}
10961096

1097-
/// Checked integer division without remainder. Computes `self / rhs`.
1098-
///
1099-
/// # Panics
1100-
///
1101-
/// This function will panic if `rhs == 0` or `self % rhs != 0`.
1097+
/// Checked integer division without remainder. Computes `self / rhs`,
1098+
/// returning `None` if `rhs == 0` or if `self % rhs != 0`.
11021099
///
11031100
/// # Examples
11041101
///
11051102
/// ```
11061103
/// #![feature(exact_div)]
1107-
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(2), 32);")]
1108-
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(32), 2);")]
1109-
/// ```
1110-
///
1111-
/// ```should_panic
1112-
/// #![feature(exact_div)]
1113-
#[doc = concat!("let _ = 65", stringify!($SelfT), ".exact_div(2);")]
1104+
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_exact_div(2), Some(32));")]
1105+
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_exact_div(32), Some(2));")]
1106+
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_exact_div(0), None);")]
1107+
#[doc = concat!("assert_eq!(65", stringify!($SelfT), ".checked_exact_div(2), None);")]
11141108
/// ```
11151109
#[unstable(
11161110
feature = "exact_div",

0 commit comments

Comments
 (0)