Skip to content

Commit

Permalink
Stabilize saturating_abs and saturating_neg
Browse files Browse the repository at this point in the history
Stabilizes the following signed integer functions with saturation
mechanics:
 * saturating_abs()
 * saturating_neg()

Closes #59983
  • Loading branch information
t-rapp committed May 4, 2020
1 parent ff4df04 commit f99344a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,7 @@ instead of overflowing.
Basic usage:
```
", $Feature, "#![feature(saturating_neg)]
assert_eq!(100", stringify!($SelfT), ".saturating_neg(), -100);
", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_neg(), -100);
assert_eq!((-100", stringify!($SelfT), ").saturating_neg(), 100);
assert_eq!(", stringify!($SelfT), "::MIN.saturating_neg(), ", stringify!($SelfT),
"::MAX);
Expand All @@ -1124,7 +1123,7 @@ assert_eq!(", stringify!($SelfT), "::MAX.saturating_neg(), ", stringify!($SelfT)
$EndFeature, "
```"),

#[unstable(feature = "saturating_neg", issue = "59983")]
#[stable(feature = "saturating_neg", since = "1.45.0")]
#[rustc_const_unstable(feature = "const_saturating_int_methods", issue = "53718")]
#[inline]
pub const fn saturating_neg(self) -> Self {
Expand All @@ -1141,8 +1140,7 @@ MIN` instead of overflowing.
Basic usage:
```
", $Feature, "#![feature(saturating_neg)]
assert_eq!(100", stringify!($SelfT), ".saturating_abs(), 100);
", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_abs(), 100);
assert_eq!((-100", stringify!($SelfT), ").saturating_abs(), 100);
assert_eq!(", stringify!($SelfT), "::MIN.saturating_abs(), ", stringify!($SelfT),
"::MAX);
Expand All @@ -1151,7 +1149,7 @@ assert_eq!((", stringify!($SelfT), "::MIN + 1).saturating_abs(), ", stringify!($
$EndFeature, "
```"),

#[unstable(feature = "saturating_neg", issue = "59983")]
#[stable(feature = "saturating_neg", since = "1.45.0")]
#[rustc_const_unstable(feature = "const_saturating_int_methods", issue = "53718")]
#[inline]
pub const fn saturating_abs(self) -> Self {
Expand Down
1 change: 0 additions & 1 deletion src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#![feature(pattern)]
#![feature(range_is_empty)]
#![feature(raw)]
#![feature(saturating_neg)]
#![feature(sort_internals)]
#![feature(slice_partition_at_index)]
#![feature(specialization)]
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const-int-arithmetic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass

#![feature(saturating_neg)]
#![feature(const_checked_int_methods)]
#![feature(const_euclidean_int_methods)]
#![feature(const_overflowing_int_methods)]
Expand Down

0 comments on commit f99344a

Please sign in to comment.