Skip to content

Commit 2d11559

Browse files
committed
Add an unchecked_div alias to the Div<NonZero<_>> impls
1 parent 9a1d156 commit 2d11559

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

library/core/src/num/nonzero.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,12 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
11651165
impl Div<NonZero<$Int>> for $Int {
11661166
type Output = $Int;
11671167

1168+
/// Same as `self / other.get()`, but because `other` is a `NonZero<_>`,
1169+
/// there's never a runtime check for division-by-zero.
1170+
///
11681171
/// This operation rounds towards zero, truncating any fractional
11691172
/// part of the exact result, and cannot panic.
1173+
#[doc(alias = "unchecked_div")]
11701174
#[inline]
11711175
fn div(self, other: NonZero<$Int>) -> $Int {
11721176
// SAFETY: Division by zero is checked because `other` is non-zero,
@@ -1177,6 +1181,9 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
11771181

11781182
#[stable(feature = "nonzero_div_assign", since = "1.79.0")]
11791183
impl DivAssign<NonZero<$Int>> for $Int {
1184+
/// Same as `self /= other.get()`, but because `other` is a `NonZero<_>`,
1185+
/// there's never a runtime check for division-by-zero.
1186+
///
11801187
/// This operation rounds towards zero, truncating any fractional
11811188
/// part of the exact result, and cannot panic.
11821189
#[inline]

0 commit comments

Comments
 (0)