delete the Neg trait bound for CheckedNeg

This commit is contained in:
LEXUGE 2018-04-06 17:06:33 +08:00
parent 138abc7b58
commit 4222b6094f
No known key found for this signature in database
GPG Key ID: AE53B4C2E58EDD45
1 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,4 @@
use core::ops::{Add, Div, Mul, Neg, Rem, Shl, Shr, Sub}; use core::ops::{Add, Div, Mul, Rem, Shl, Shr, Sub};
/// Performs addition that returns `None` instead of wrapping around on /// Performs addition that returns `None` instead of wrapping around on
/// overflow. /// overflow.
@ -119,10 +119,16 @@ macro_rules! checked_impl_one_para {
} }
} }
pub trait CheckedNeg: Sized + Neg<Output = Self> { pub trait CheckedNeg: Sized {
fn checked_neg(&self) -> Option<Self>; fn checked_neg(&self) -> Option<Self>;
} }
checked_impl_one_para!(CheckedNeg, checked_neg, u8);
checked_impl_one_para!(CheckedNeg, checked_neg, u16);
checked_impl_one_para!(CheckedNeg, checked_neg, u32);
checked_impl_one_para!(CheckedNeg, checked_neg, u64);
checked_impl_one_para!(CheckedNeg, checked_neg, usize);
checked_impl_one_para!(CheckedNeg, checked_neg, i8); checked_impl_one_para!(CheckedNeg, checked_neg, i8);
checked_impl_one_para!(CheckedNeg, checked_neg, i16); checked_impl_one_para!(CheckedNeg, checked_neg, i16);
checked_impl_one_para!(CheckedNeg, checked_neg, i32); checked_impl_one_para!(CheckedNeg, checked_neg, i32);