Add negation operator for Sign
All checks were successful
timw4mail/rusty-numbers/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2020-03-06 12:26:15 -05:00
parent 4ac9f7e888
commit d0ac326944

View File

@ -7,7 +7,7 @@ use core::convert::TryFrom;
use core::fmt::Debug; use core::fmt::Debug;
use core::ops::{ use core::ops::{
Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign, Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
Mul, MulAssign, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign,
}; };
/// Represents the sign of a rational number /// Represents the sign of a rational number
@ -27,8 +27,16 @@ impl Default for Sign {
} }
} }
impl Neg for Sign {
type Output = Self;
fn neg(self) -> Self::Output {
!self
}
}
impl Not for Sign { impl Not for Sign {
type Output = Sign; type Output = Self;
fn not(self) -> Self::Output { fn not(self) -> Self::Output {
match self { match self {