Skip to content

Commit d9d5c66

Browse files
authored
Rollup merge of rust-lang#46947 - tspiteri:checked-div-rem-none, r=frewsxcv
doc: improve None condition doc for `checked_div` and `checked_rem` This commit improves the condition mentioned in the docs for which `checked_div` and `checked_rem` return `None`. For signed division, the commit changes "the operation results in overflow" to "the division results in overflow", otherwise there is room for misinterpretation for `checked_rem`: Without considering overflow, `MIN % -1` would be simply zero, allowing the misinterpretation that "the operation" does not result in overflow in this case. This ambiguity is removed using "when the division results in overflow". For unsigned division, the condition for `None` should be simply when `rhs == 0`, as no other overflow is possible.
2 parents 72176cf + f2c5472 commit d9d5c66

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/libcore/num/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ macro_rules! int_impl {
439439
}
440440

441441
/// Checked integer division. Computes `self / rhs`, returning `None`
442-
/// if `rhs == 0` or the operation results in overflow.
442+
/// if `rhs == 0` or the division results in overflow.
443443
///
444444
/// # Examples
445445
///
@@ -461,7 +461,7 @@ macro_rules! int_impl {
461461
}
462462

463463
/// Checked integer remainder. Computes `self % rhs`, returning `None`
464-
/// if `rhs == 0` or the operation results in overflow.
464+
/// if `rhs == 0` or the division results in overflow.
465465
///
466466
/// # Examples
467467
///
@@ -1607,7 +1607,7 @@ macro_rules! uint_impl {
16071607
}
16081608

16091609
/// Checked integer division. Computes `self / rhs`, returning `None`
1610-
/// if `rhs == 0` or the operation results in overflow.
1610+
/// if `rhs == 0`.
16111611
///
16121612
/// # Examples
16131613
///
@@ -1627,7 +1627,7 @@ macro_rules! uint_impl {
16271627
}
16281628

16291629
/// Checked integer remainder. Computes `self % rhs`, returning `None`
1630-
/// if `rhs == 0` or the operation results in overflow.
1630+
/// if `rhs == 0`.
16311631
///
16321632
/// # Examples
16331633
///

0 commit comments

Comments
 (0)