Skip to content

Commit d4c9f76

Browse files
committed
Fix missed tests
1 parent cdc90f9 commit d4c9f76

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

library/core/src/num/saturating.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ macro_rules! saturating_int_impl_signed {
626626
/// #![feature(saturating_int_impl)]
627627
/// use std::num::Saturating;
628628
///
629-
#[doc = concat!("let n = Saturating(", stringify!($t), "::MAX) / 4;")]
629+
#[doc = concat!("let n = Saturating(", stringify!($t), "::MAX) / Saturating(4", stringify!($t), ");")]
630630
///
631631
/// assert_eq!(n.leading_zeros(), 3);
632632
/// ```
@@ -636,12 +636,8 @@ macro_rules! saturating_int_impl_signed {
636636
self.0.leading_zeros()
637637
}
638638

639-
/// Computes the absolute value of `self`, saturating around at
640-
/// the boundary of the type.
641-
///
642-
/// The only case where such saturating can occur is when one takes the absolute value of the negative
643-
/// minimal value for the type this is a positive value that is too large to represent in the type. In
644-
/// such a case, this function returns `MIN` itself.
639+
/// Saturating absolute value. Computes `self.abs()`, returning `MAX` if `self == MIN`
640+
/// instead of overflowing.
645641
///
646642
/// # Examples
647643
///
@@ -653,8 +649,9 @@ macro_rules! saturating_int_impl_signed {
653649
///
654650
#[doc = concat!("assert_eq!(Saturating(100", stringify!($t), ").abs(), Saturating(100));")]
655651
#[doc = concat!("assert_eq!(Saturating(-100", stringify!($t), ").abs(), Saturating(100));")]
656-
#[doc = concat!("assert_eq!(Saturating(", stringify!($t), "::MIN).abs(), Saturating(", stringify!($t), "::MIN));")]
657-
/// assert_eq!(Saturating(-128i8).abs().0 as u8, 128u8);
652+
#[doc = concat!("assert_eq!(Saturating(", stringify!($t), "::MIN).abs(), Saturating((", stringify!($t), "::MIN + 1).abs()));")]
653+
#[doc = concat!("assert_eq!(Saturating(", stringify!($t), "::MIN).abs(), Saturating(", stringify!($t), "::MIN.saturating_abs()));")]
654+
/// assert_eq!(Saturating(-128i8).abs().0 as u8, i8::MAX as u8);
658655
/// ```
659656
#[inline]
660657
#[unstable(feature = "saturating_int_impl", issue = "87920")]
@@ -744,7 +741,7 @@ macro_rules! saturating_int_impl_unsigned {
744741
/// #![feature(saturating_int_impl)]
745742
/// use std::num::Saturating;
746743
///
747-
#[doc = concat!("let n = Saturating(", stringify!($t), "::MAX) / 4;")]
744+
#[doc = concat!("let n = Saturating(", stringify!($t), "::MAX) / Saturating(4", stringify!($t), ");")]
748745
///
749746
/// assert_eq!(n.leading_zeros(), 2);
750747
/// ```

0 commit comments

Comments
 (0)