Skip to content

Commit 6afbf14

Browse files
committed
Shorten nonzero isqrt internal comment
1 parent 7e2fe31 commit 6afbf14

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

library/core/src/num/nonzero.rs

+8-16
Original file line numberDiff line numberDiff line change
@@ -1547,24 +1547,16 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
15471547
pub const fn isqrt(self) -> Self {
15481548
let result = self.get().isqrt();
15491549

1550-
// SAFETY: Inform the optimizer what the range of outputs is.
1551-
// If testing `core` crashes with no panic message and a
1552-
// `num::int_sqrt::u*` test failed, it's because your edits
1553-
// caused these assertions or the assertions in `fn isqrt` of
1554-
// `uint_macros.rs` to become false.
1550+
// Inform the optimizer what the range of outputs is. The upper
1551+
// bound was already handled by the `$Uint::isqrt` call just above.
15551552
//
1556-
// Integer square root is a monotonically nondecreasing
1557-
// function, which means that increasing the input will never
1558-
// cause the output to decrease.
1559-
//
1560-
// The minimum input is 1. When n is 1, sqrt(n) is 1. If n
1561-
// increases above 1, sqrt(n) can't decrease below 1, so sqrt(n)
1562-
// can't decrease below 1 no matter what n is.
1563-
//
1564-
// The maximum possible output already has an assertion in
1565-
// `fn isqrt` of `uint_macros.rs`.
1553+
// SAFETY: Integer square root is a monotonically nondecreasing
1554+
// function, which means that increasing the input will never cause
1555+
// the output to decrease. Thus, since the input for nonzero
1556+
// unsigned integers has a lower bound of 1, the lower bound of the
1557+
// result will be sqrt(1), which is 1.
15661558
unsafe {
1567-
hint::assert_unchecked(result > 0);
1559+
hint::assert_unchecked(result >= 1);
15681560
}
15691561

15701562
// SAFETY: As explained above, the minimum integer square root is

0 commit comments

Comments
 (0)