Add negation operator for Sign
All checks were successful
timw4mail/rusty-numbers/pipeline/head This commit looks good
All checks were successful
timw4mail/rusty-numbers/pipeline/head This commit looks good
This commit is contained in:
parent
4ac9f7e888
commit
d0ac326944
12
src/num.rs
12
src/num.rs
@ -7,7 +7,7 @@ use core::convert::TryFrom;
|
||||
use core::fmt::Debug;
|
||||
use core::ops::{
|
||||
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
|
||||
@ -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 {
|
||||
type Output = Sign;
|
||||
type Output = Self;
|
||||
|
||||
fn not(self) -> Self::Output {
|
||||
match self {
|
||||
|
Loading…
Reference in New Issue
Block a user