提交 3c168b0d 编写于 作者: I Iago-lito

Explicit what `check` means on concerned method.

上级 b8056d8e
......@@ -42,7 +42,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
pub struct $Ty($Int);
impl $Ty {
/// Creates a non-zero without checking the value.
/// Creates a non-zero without checking whether the value is non-zero.
/// This results in undefined behaviour if the value is zero.
///
/// # Safety
///
......@@ -291,7 +292,9 @@ fn rem(self, other: $Ty) -> $Int {
$(
impl $Ty {
/// Add an unsigned integer to a non-zero value.
/// Return [`None`] on overflow.
/// Check for overflow and return [`None`] on overflow
/// As a consequence, the result cannot wrap to zero.
///
///
/// # Examples
///
......@@ -354,7 +357,9 @@ pub const fn saturating_add(self, other: $Int) -> $Ty {
/// Add an unsigned integer to a non-zero value,
/// assuming overflow cannot occur.
/// This results in undefined behaviour when
/// Overflow is unchecked, and it is undefined behaviour to overflow
/// *even if the result would wrap to a non-zero value*.
/// The behaviour is undefined as soon as
#[doc = concat!("`self + rhs > ", stringify!($Int), "::MAX`")]
#[doc = concat!(" or `self + rhs < ", stringify!($Int), "::MIN`.")]
///
......@@ -381,8 +386,9 @@ pub unsafe fn unchecked_add(self, other: $Int) -> $Ty {
}
/// Returns the smallest power of two greater than or equal to n.
/// If the next power of two is greater than the type’s maximum value,
/// [`None`] is returned, otherwise the power of two is wrapped in [`Some`].
/// Check for overflow and return [`None`]
/// if the next power of two is greater than the type’s maximum value.
/// As a consequence, the result cannot wrap to zero.
///
/// # Examples
///
......@@ -462,8 +468,9 @@ pub const fn abs(self) -> $Ty {
}
/// Checked absolute value.
/// Returns [`None`] if
/// Check for overflow and returns [`None`] if
#[doc = concat!("`self == ", stringify!($Int), "::MIN`.")]
/// The result cannot be zero.
///
/// # Example
///
......@@ -647,7 +654,8 @@ pub const fn unsigned_abs(self) -> $Uty {
$(
impl $Ty {
/// Multiply two non-zero integers together.
/// Return [`None`] on overflow.
/// Check for overflow and return [`None`] on overflow.
/// As a consequence, the result cannot wrap to zero.
///
/// # Examples
///
......@@ -712,7 +720,9 @@ pub const fn saturating_mul(self, other: $Ty) -> $Ty {
/// Multiply two non-zero integers together,
/// assuming overflow cannot occur.
/// This results in undefined behavior when
/// Overflow is unchecked, and it is undefined behaviour to overflow
/// *even if the result would wrap to a non-zero value*.
/// The behaviour is undefined as soon as
#[doc = concat!("`self * rhs > ", stringify!($Int), "::MAX`, ")]
#[doc = concat!("or `self * rhs < ", stringify!($Int), "::MIN`.")]
///
......@@ -739,7 +749,8 @@ pub unsafe fn unchecked_mul(self, other: $Ty) -> $Ty {
}
/// Raise non-zero value to an integer power.
/// Return [`None`] on overflow.
/// Check for overflow and return [`None`] on overflow.
/// As a consequence, the result cannot wrap to zero.
///
/// # Examples
///
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册