Make saturating arithmetic using intrinsics const
This commit is contained in:
parent
526304da16
commit
dda015aebc
1 changed files with 4 additions and 2 deletions
|
@ -1091,8 +1091,9 @@ $EndFeature, "
|
||||||
```"),
|
```"),
|
||||||
|
|
||||||
#[unstable(feature = "saturating_neg", issue = "59983")]
|
#[unstable(feature = "saturating_neg", issue = "59983")]
|
||||||
|
#[rustc_const_unstable(feature = "const_int_saturating", issue = "53718")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn saturating_neg(self) -> Self {
|
pub const fn saturating_neg(self) -> Self {
|
||||||
intrinsics::saturating_sub(0, self)
|
intrinsics::saturating_sub(0, self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1117,8 +1118,9 @@ $EndFeature, "
|
||||||
```"),
|
```"),
|
||||||
|
|
||||||
#[unstable(feature = "saturating_neg", issue = "59983")]
|
#[unstable(feature = "saturating_neg", issue = "59983")]
|
||||||
|
#[rustc_const_unstable(feature = "const_int_saturating", issue = "53718")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn saturating_abs(self) -> Self {
|
pub const fn saturating_abs(self) -> Self {
|
||||||
if self.is_negative() {
|
if self.is_negative() {
|
||||||
self.saturating_neg()
|
self.saturating_neg()
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue