1 use crate::traits::SignedInteger;
2 #[cfg(__standback_before_1_43)]
3 use crate::v1_43::int_v1_43;
4 
5 pub trait int_v1_45: SignedInteger {
saturating_neg(self) -> Self6     fn saturating_neg(self) -> Self;
saturating_abs(self) -> Self7     fn saturating_abs(self) -> Self;
8 }
9 
10 macro_rules! impl_int_v1_45 {
11     ($($type:ty),*) => {$(
12         impl int_v1_45 for $type {
13             fn saturating_neg(self) -> Self {
14                 if self == Self::MIN {
15                     Self::MAX
16                 } else {
17                     -self
18                 }
19             }
20 
21             fn saturating_abs(self) -> Self {
22                 if self.is_negative() {
23                     self.saturating_neg()
24                 } else {
25                     self
26                 }
27             }
28         }
29     )*};
30 }
31 
32 impl_int_v1_45![i8, i16, i32, i64, i128, isize];
33