Skip to content

Commit 651cd0f

Browse files
committed
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.
1 parent 0f35336 commit 651cd0f

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

library/core/src/num/uint_macros.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,23 +1103,16 @@ macro_rules! uint_impl {
11031103
self / rhs
11041104
}
11051105

1106-
/// Checked integer division without remainder. Computes `self / rhs`.
1107-
///
1108-
/// # Panics
1109-
///
1110-
/// This function will panic if `rhs == 0` or `self % rhs != 0`.
1106+
/// Checked integer division without remainder. Computes `self / rhs`,
1107+
/// returning `None` if `rhs == 0` or if `self % rhs != 0`.
11111108
///
11121109
/// # Examples
11131110
///
11141111
/// ```
11151112
/// #![feature(exact_div)]
1116-
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(2), 32);")]
1117-
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".exact_div(32), 2);")]
1118-
/// ```
1119-
///
1120-
/// ```should_panic
1121-
/// #![feature(exact_div)]
1122-
#[doc = concat!("let _ = 65", stringify!($SelfT), ".exact_div(2);")]
1113+
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_exact_div(2), Some(32));")]
1114+
#[doc = concat!("assert_eq!(64", stringify!($SelfT), ".checked_exact_div(32), Some(2));")]
1115+
#[doc = concat!("assert_eq!(65", stringify!($SelfT), ".checked_exact_div(2), None);")]
11231116
/// ```
11241117
#[unstable(
11251118
feature = "exact_div",

0 commit comments

Comments
 (0)