summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-09-07 21:58:53 +0200
committerMatthias Beyer <mail@beyermatthias.de>2017-09-07 21:58:53 +0200
commitccbfa776c69adb02235eacf7d72d9a2adc596f49 (patch)
tree2d38645fadef84fdc52db713fe7eaab66296eab6
parentb5bf171b8b2572261a37b4d0e57a9a673412a478 (diff)
Impl AddAssign and SubAssign for TimeType
-rw-r--r--src/timetype.rs14
1 files changed, 14 insertions, 0 deletions
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