]> git.lizzy.rs Git - rust.git/blobdiff - library/core/src/num/saturating.rs
Implement Neg only for signed Saturating types
[rust.git] / library / core / src / num / saturating.rs
index b0a172c72d0bde5eb52d39d3b6bebad1084b38f3..3bb668d9340b4161774890357401052ca1c3d070 100644 (file)
@@ -384,17 +384,6 @@ fn bitand_assign(&mut self, other: Saturating<$t>) {
         }
         forward_ref_op_assign! { impl BitAndAssign, bitand_assign for Saturating<$t>, Saturating<$t> }
 
-        #[unstable(feature = "saturating_int_impl", issue = "87920")]
-        impl Neg for Saturating<$t> {
-            type Output = Self;
-            #[inline]
-            fn neg(self) -> Self {
-                Saturating(0) - self
-            }
-        }
-        forward_ref_unop! { impl Neg, neg for Saturating<$t>,
-                #[unstable(feature = "saturating_int_impl", issue = "87920")] }
-
     )*)
 }
 
@@ -864,6 +853,17 @@ pub const fn is_negative(self) -> bool {
                 self.0.is_negative()
             }
         }
+
+        #[unstable(feature = "saturating_int_impl", issue = "87920")]
+        impl Neg for Saturating<$t> {
+            type Output = Self;
+            #[inline]
+            fn neg(self) -> Self {
+                Saturating(self.0.saturating_neg())
+            }
+        }
+        forward_ref_unop! { impl Neg, neg for Saturating<$t>,
+                #[unstable(feature = "saturating_int_impl", issue = "87920")] }
     )*)
 }