Skip to content

Commit f136eea

Browse files
committed
Implement Neg only for signed Saturating types
1 parent 7861121 commit f136eea

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

library/core/src/num/saturating.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -384,17 +384,6 @@ macro_rules! saturating_impl {
384384
}
385385
forward_ref_op_assign! { impl BitAndAssign, bitand_assign for Saturating<$t>, Saturating<$t> }
386386

387-
#[unstable(feature = "saturating_int_impl", issue = "87920")]
388-
impl Neg for Saturating<$t> {
389-
type Output = Self;
390-
#[inline]
391-
fn neg(self) -> Self {
392-
Saturating(0) - self
393-
}
394-
}
395-
forward_ref_unop! { impl Neg, neg for Saturating<$t>,
396-
#[unstable(feature = "saturating_int_impl", issue = "87920")] }
397-
398387
)*)
399388
}
400389

@@ -864,6 +853,17 @@ macro_rules! saturating_int_impl_signed {
864853
self.0.is_negative()
865854
}
866855
}
856+
857+
#[unstable(feature = "saturating_int_impl", issue = "87920")]
858+
impl Neg for Saturating<$t> {
859+
type Output = Self;
860+
#[inline]
861+
fn neg(self) -> Self {
862+
Saturating(self.0.saturating_neg())
863+
}
864+
}
865+
forward_ref_unop! { impl Neg, neg for Saturating<$t>,
866+
#[unstable(feature = "saturating_int_impl", issue = "87920")] }
867867
)*)
868868
}
869869

0 commit comments

Comments
 (0)