Rollup merge of #71886 - t-rapp:tr-saturating-funcs, r=dtolnay
Stabilize saturating_abs and saturating_neg Stabilizes the following signed integer functions with saturation mechanics: * saturating_abs() * saturating_neg() Closes #59983
This commit is contained in:
commit
4c48f5ab69
3 changed files with 4 additions and 8 deletions
|
@ -1165,8 +1165,7 @@ instead of overflowing.
|
||||||
Basic usage:
|
Basic usage:
|
||||||
|
|
||||||
```
|
```
|
||||||
", $Feature, "#![feature(saturating_neg)]
|
", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_neg(), -100);
|
||||||
assert_eq!(100", stringify!($SelfT), ".saturating_neg(), -100);
|
|
||||||
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),
|
assert_eq!(", stringify!($SelfT), "::MIN.saturating_neg(), ", stringify!($SelfT),
|
||||||
"::MAX);
|
"::MAX);
|
||||||
|
@ -1175,7 +1174,7 @@ assert_eq!(", stringify!($SelfT), "::MAX.saturating_neg(), ", stringify!($SelfT)
|
||||||
$EndFeature, "
|
$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")]
|
#[rustc_const_unstable(feature = "const_saturating_int_methods", issue = "53718")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn saturating_neg(self) -> Self {
|
pub const fn saturating_neg(self) -> Self {
|
||||||
|
@ -1192,8 +1191,7 @@ MIN` instead of overflowing.
|
||||||
Basic usage:
|
Basic usage:
|
||||||
|
|
||||||
```
|
```
|
||||||
", $Feature, "#![feature(saturating_neg)]
|
", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_abs(), 100);
|
||||||
assert_eq!(100", stringify!($SelfT), ".saturating_abs(), 100);
|
|
||||||
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),
|
assert_eq!(", stringify!($SelfT), "::MIN.saturating_abs(), ", stringify!($SelfT),
|
||||||
"::MAX);
|
"::MAX);
|
||||||
|
@ -1202,7 +1200,7 @@ assert_eq!((", stringify!($SelfT), "::MIN + 1).saturating_abs(), ", stringify!($
|
||||||
$EndFeature, "
|
$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")]
|
#[rustc_const_unstable(feature = "const_saturating_int_methods", issue = "53718")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn saturating_abs(self) -> Self {
|
pub const fn saturating_abs(self) -> Self {
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#![feature(pattern)]
|
#![feature(pattern)]
|
||||||
#![feature(range_is_empty)]
|
#![feature(range_is_empty)]
|
||||||
#![feature(raw)]
|
#![feature(raw)]
|
||||||
#![feature(saturating_neg)]
|
|
||||||
#![feature(sort_internals)]
|
#![feature(sort_internals)]
|
||||||
#![feature(slice_partition_at_index)]
|
#![feature(slice_partition_at_index)]
|
||||||
#![feature(specialization)]
|
#![feature(specialization)]
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// run-pass
|
// run-pass
|
||||||
|
|
||||||
#![feature(saturating_neg)]
|
|
||||||
#![feature(const_checked_int_methods)]
|
#![feature(const_checked_int_methods)]
|
||||||
#![feature(const_euclidean_int_methods)]
|
#![feature(const_euclidean_int_methods)]
|
||||||
#![feature(const_overflowing_int_methods)]
|
#![feature(const_overflowing_int_methods)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue