about summary refs log tree commit diff
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2025-01-24 09:51:59 -0800
committerScott McMurray <scottmcm@users.noreply.github.com>2025-01-24 09:51:59 -0800
commit2d11559f56bbe112b13d2fe43fbfd40b7258f34e (patch)
treeb6f04b494249b39c1bb832534b2dd2650ff999b7
parent9a1d156f38c51441ee51e5a068f1d0caf4bb0f27 (diff)
downloadrust-2d11559f56bbe112b13d2fe43fbfd40b7258f34e.tar.gz
rust-2d11559f56bbe112b13d2fe43fbfd40b7258f34e.zip
Add an `unchecked_div` alias to the `Div<NonZero<_>>` impls
-rw-r--r--library/core/src/num/nonzero.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs
index dbce64420ac..51f407096cf 100644
--- a/library/core/src/num/nonzero.rs
+++ b/library/core/src/num/nonzero.rs
@@ -1165,8 +1165,12 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
         impl Div<NonZero<$Int>> for $Int {
             type Output = $Int;
 
+            /// Same as `self / other.get()`, but because `other` is a `NonZero<_>`,
+            /// there's never a runtime check for division-by-zero.
+            ///
             /// This operation rounds towards zero, truncating any fractional
             /// part of the exact result, and cannot panic.
+            #[doc(alias = "unchecked_div")]
             #[inline]
             fn div(self, other: NonZero<$Int>) -> $Int {
                 // SAFETY: Division by zero is checked because `other` is non-zero,
@@ -1177,6 +1181,9 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
 
         #[stable(feature = "nonzero_div_assign", since = "1.79.0")]
         impl DivAssign<NonZero<$Int>> for $Int {
+            /// Same as `self /= other.get()`, but because `other` is a `NonZero<_>`,
+            /// there's never a runtime check for division-by-zero.
+            ///
             /// This operation rounds towards zero, truncating any fractional
             /// part of the exact result, and cannot panic.
             #[inline]