Implement Rem and RemAssign for Number
This commit is contained in:
parent
201f97a914
commit
65c5c209f3
@ -1,6 +1,6 @@
|
||||
use std::convert::From;
|
||||
use std::fmt::{self, Display, Write};
|
||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
|
||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, RemAssign, Sub, SubAssign};
|
||||
|
||||
use num_bigint::BigInt;
|
||||
use num_rational::BigRational;
|
||||
@ -172,3 +172,19 @@ impl DivAssign for Number {
|
||||
self.val /= other.val
|
||||
}
|
||||
}
|
||||
|
||||
impl Rem for Number {
|
||||
type Output = Self;
|
||||
|
||||
fn rem(self, other: Self) -> Self {
|
||||
Number {
|
||||
val: self.val % other.val,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RemAssign for Number {
|
||||
fn rem_assign(&mut self, other: Self) {
|
||||
self.val %= other.val
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user