]> git.lizzy.rs Git - rust.git/commitdiff
Make saturating arithmetic using intrinsics `const`
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Mon, 3 Feb 2020 21:17:13 +0000 (13:17 -0800)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Tue, 4 Feb 2020 19:04:04 +0000 (11:04 -0800)
src/libcore/num/mod.rs

index f590c6bc7c285099e3a202580eba45334e094ba6..38989004f9147be7af8bce2b71cc0e4fa06b5d95 100644 (file)
@@ -1091,8 +1091,9 @@ pub const fn saturating_sub(self, rhs: Self) -> Self {
 ```"),
 
             #[unstable(feature = "saturating_neg", issue = "59983")]
+            #[rustc_const_unstable(feature = "const_int_saturating", issue = "53718")]
             #[inline]
-            pub fn saturating_neg(self) -> Self {
+            pub const fn saturating_neg(self) -> Self {
                 intrinsics::saturating_sub(0, self)
             }
         }
@@ -1117,8 +1118,9 @@ pub fn saturating_neg(self) -> Self {
 ```"),
 
             #[unstable(feature = "saturating_neg", issue = "59983")]
+            #[rustc_const_unstable(feature = "const_int_saturating", issue = "53718")]
             #[inline]
-            pub fn saturating_abs(self) -> Self {
+            pub const fn saturating_abs(self) -> Self {
                 if self.is_negative() {
                     self.saturating_neg()
                 } else {