Skip to content

Commit dda015a

Browse files
Make saturating arithmetic using intrinsics const
1 parent 526304d commit dda015a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/libcore/num/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,9 @@ $EndFeature, "
10911091
```"),
10921092

10931093
#[unstable(feature = "saturating_neg", issue = "59983")]
1094+
#[rustc_const_unstable(feature = "const_int_saturating", issue = "53718")]
10941095
#[inline]
1095-
pub fn saturating_neg(self) -> Self {
1096+
pub const fn saturating_neg(self) -> Self {
10961097
intrinsics::saturating_sub(0, self)
10971098
}
10981099
}
@@ -1117,8 +1118,9 @@ $EndFeature, "
11171118
```"),
11181119

11191120
#[unstable(feature = "saturating_neg", issue = "59983")]
1121+
#[rustc_const_unstable(feature = "const_int_saturating", issue = "53718")]
11201122
#[inline]
1121-
pub fn saturating_abs(self) -> Self {
1123+
pub const fn saturating_abs(self) -> Self {
11221124
if self.is_negative() {
11231125
self.saturating_neg()
11241126
} else {

0 commit comments

Comments
 (0)