@@ -42,7 +42,8 @@ macro_rules! nonzero_integers {
4242 pub struct $Ty( $Int) ;
4343
4444 impl $Ty {
45- /// Creates a non-zero without checking the value.
45+ /// Creates a non-zero without checking whether the value is non-zero.
46+ /// This results in undefined behaviour if the value is zero.
4647 ///
4748 /// # Safety
4849 ///
@@ -291,7 +292,9 @@ macro_rules! nonzero_unsigned_operations {
291292 $(
292293 impl $Ty {
293294 /// Add an unsigned integer to a non-zero value.
294- /// Return [`None`] on overflow.
295+ /// Check for overflow and return [`None`] on overflow
296+ /// As a consequence, the result cannot wrap to zero.
297+ ///
295298 ///
296299 /// # Examples
297300 ///
@@ -354,7 +357,9 @@ macro_rules! nonzero_unsigned_operations {
354357
355358 /// Add an unsigned integer to a non-zero value,
356359 /// assuming overflow cannot occur.
357- /// This results in undefined behaviour when
360+ /// Overflow is unchecked, and it is undefined behaviour to overflow
361+ /// *even if the result would wrap to a non-zero value*.
362+ /// The behaviour is undefined as soon as
358363 #[ doc = concat!( "`self + rhs > " , stringify!( $Int) , "::MAX`" ) ]
359364 #[ doc = concat!( " or `self + rhs < " , stringify!( $Int) , "::MIN`." ) ]
360365 ///
@@ -381,8 +386,9 @@ macro_rules! nonzero_unsigned_operations {
381386 }
382387
383388 /// Returns the smallest power of two greater than or equal to n.
384- /// If the next power of two is greater than the type’s maximum value,
385- /// [`None`] is returned, otherwise the power of two is wrapped in [`Some`].
389+ /// Check for overflow and return [`None`]
390+ /// if the next power of two is greater than the type’s maximum value.
391+ /// As a consequence, the result cannot wrap to zero.
386392 ///
387393 /// # Examples
388394 ///
@@ -462,8 +468,9 @@ macro_rules! nonzero_signed_operations {
462468 }
463469
464470 /// Checked absolute value.
465- /// Returns [`None`] if
471+ /// Check for overflow and returns [`None`] if
466472 #[ doc = concat!( "`self == " , stringify!( $Int) , "::MIN`." ) ]
473+ /// The result cannot be zero.
467474 ///
468475 /// # Example
469476 ///
@@ -647,7 +654,8 @@ macro_rules! nonzero_unsigned_signed_operations {
647654 $(
648655 impl $Ty {
649656 /// Multiply two non-zero integers together.
650- /// Return [`None`] on overflow.
657+ /// Check for overflow and return [`None`] on overflow.
658+ /// As a consequence, the result cannot wrap to zero.
651659 ///
652660 /// # Examples
653661 ///
@@ -712,7 +720,9 @@ macro_rules! nonzero_unsigned_signed_operations {
712720
713721 /// Multiply two non-zero integers together,
714722 /// assuming overflow cannot occur.
715- /// This results in undefined behavior when
723+ /// Overflow is unchecked, and it is undefined behaviour to overflow
724+ /// *even if the result would wrap to a non-zero value*.
725+ /// The behaviour is undefined as soon as
716726 #[ doc = concat!( "`self * rhs > " , stringify!( $Int) , "::MAX`, " ) ]
717727 #[ doc = concat!( "or `self * rhs < " , stringify!( $Int) , "::MIN`." ) ]
718728 ///
@@ -739,7 +749,8 @@ macro_rules! nonzero_unsigned_signed_operations {
739749 }
740750
741751 /// Raise non-zero value to an integer power.
742- /// Return [`None`] on overflow.
752+ /// Check for overflow and return [`None`] on overflow.
753+ /// As a consequence, the result cannot wrap to zero.
743754 ///
744755 /// # Examples
745756 ///
0 commit comments