Apply suggestions
Co-authored-by: kennytm <kennytm@gmail.com>
This commit is contained in:
parent
9faf621355
commit
70e55a8938
1 changed files with 6 additions and 12 deletions
|
@ -501,7 +501,7 @@ macro_rules! int_impl {
|
||||||
unsafe { intrinsics::unchecked_sub(self, rhs) }
|
unsafe { intrinsics::unchecked_sub(self, rhs) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checked addition with an unsigned integer. Computes `self + rhs`,
|
/// Checked subtraction with an unsigned integer. Computes `self - rhs`,
|
||||||
/// returning `None` if overflow occurred.
|
/// returning `None` if overflow occurred.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
@ -885,10 +885,7 @@ macro_rules! int_impl {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn saturating_add_unsigned(self, rhs: $UnsignedT) -> Self {
|
pub const fn saturating_add_unsigned(self, rhs: $UnsignedT) -> Self {
|
||||||
// Overflow can only happen at the upper bound
|
// Overflow can only happen at the upper bound
|
||||||
match self.checked_add_unsigned(rhs) {
|
self.checked_add_unsigned(rhs).unwrap_or(Self::MAX)
|
||||||
Some(x) => x,
|
|
||||||
None => Self::MAX,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Saturating integer subtraction. Computes `self - rhs`, saturating at the
|
/// Saturating integer subtraction. Computes `self - rhs`, saturating at the
|
||||||
|
@ -912,7 +909,7 @@ macro_rules! int_impl {
|
||||||
intrinsics::saturating_sub(self, rhs)
|
intrinsics::saturating_sub(self, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Saturating substraction with an unsigned integer. Computes `self - rhs`,
|
/// Saturating subtraction with an unsigned integer. Computes `self - rhs`,
|
||||||
/// saturating at the numeric bounds instead of overflowing.
|
/// saturating at the numeric bounds instead of overflowing.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
@ -931,10 +928,7 @@ macro_rules! int_impl {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn saturating_sub_unsigned(self, rhs: $UnsignedT) -> Self {
|
pub const fn saturating_sub_unsigned(self, rhs: $UnsignedT) -> Self {
|
||||||
// Overflow can only happen at the lower bound
|
// Overflow can only happen at the lower bound
|
||||||
match self.checked_sub_unsigned(rhs) {
|
self.checked_sub_unsigned(rhs).unwrap_or(Self::MIN)
|
||||||
Some(x) => x,
|
|
||||||
None => Self::MIN,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Saturating integer negation. Computes `-self`, returning `MAX` if `self == MIN`
|
/// Saturating integer negation. Computes `-self`, returning `MAX` if `self == MIN`
|
||||||
|
@ -1133,7 +1127,7 @@ macro_rules! int_impl {
|
||||||
intrinsics::wrapping_sub(self, rhs)
|
intrinsics::wrapping_sub(self, rhs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wrapping (modular) substraction with an unsigned integer. Computes
|
/// Wrapping (modular) subtraction with an unsigned integer. Computes
|
||||||
/// `self - rhs`, wrapping around at the boundary of the type.
|
/// `self - rhs`, wrapping around at the boundary of the type.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
@ -1584,7 +1578,7 @@ macro_rules! int_impl {
|
||||||
|
|
||||||
/// Calculates `self` - `rhs` with an unsigned `rhs`
|
/// Calculates `self` - `rhs` with an unsigned `rhs`
|
||||||
///
|
///
|
||||||
/// Returns a tuple of the substraction along with a boolean indicating
|
/// Returns a tuple of the subtraction along with a boolean indicating
|
||||||
/// whether an arithmetic overflow would occur. If an overflow would
|
/// whether an arithmetic overflow would occur. If an overflow would
|
||||||
/// have occurred then the wrapped value is returned.
|
/// have occurred then the wrapped value is returned.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue