From 9143286e9c8972432e858797c7ab4583db5e2f56 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Tue, 19 Jan 2021 00:29:04 -0600 Subject: [PATCH] feat: implement more operator overrides for Cycles --- src/instruction.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/instruction.rs b/src/instruction.rs index 527f6df..00ce7ea 100644 --- a/src/instruction.rs +++ b/src/instruction.rs @@ -2136,12 +2136,30 @@ impl std::ops::Rem for Cycles { } } +impl std::ops::RemAssign for Cycles { + fn rem_assign(&mut self, rhs: Self) { + *self = Self(self.0 % rhs.0); + } +} + +impl std::ops::RemAssign for Cycles { + fn rem_assign(&mut self, rhs: u32) { + *self = Self(self.0 % rhs); + } +} + impl From for Cycles { fn from(num: u32) -> Self { Self(num) } } +impl From for u32 { + fn from(cycles: Cycles) -> Self { + cycles.0 + } +} + #[cfg(test)] mod tests { use super::Cycles;