From 65c5c209f3c1fa140312f4c4f805494cf7b605e1 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Fri, 14 Feb 2020 09:44:46 -0500 Subject: [PATCH] Implement Rem and RemAssign for Number --- src/value/number.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/value/number.rs b/src/value/number.rs index f11343d..0f73979 100644 --- a/src/value/number.rs +++ b/src/value/number.rs @@ -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 + } +}