From ccbfa776c69adb02235eacf7d72d9a2adc596f49 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 7 Sep 2017 21:58:53 +0200 Subject: Impl AddAssign and SubAssign for TimeType --- src/timetype.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/timetype.rs b/src/timetype.rs index a895ea1..5df7c23 100644 --- a/src/timetype.rs +++ b/src/timetype.rs @@ -4,7 +4,9 @@ use chrono::NaiveDateTime; use std::ops::Add; +use std::ops::AddAssign; use std::ops::Sub; +use std::ops::SubAssign; use result::Result; use error::KairosErrorKind as KEK; @@ -30,6 +32,12 @@ impl Add for TimeType { } } +impl AddAssign for TimeType { + fn add_assign(&mut self, rhs: TimeType) { + *self = TimeType::Addition(Box::new(self.clone()), Box::new(rhs)); + } +} + impl Sub for TimeType { type Output = TimeType; @@ -38,6 +46,12 @@ impl Sub for TimeType { } } +impl SubAssign for TimeType { + fn sub_assign(&mut self, rhs: TimeType) { + *self = TimeType::Subtraction(Box::new(self.clone()), Box::new(rhs)); + } +} + /// The TimeType type /// /// # Warning -- cgit v1.2.3