diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2017-09-02 16:02:30 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2017-09-02 16:04:40 +0200 |
commit | d51932e63fb623e25757aa7fb64e3e2ca137a2c6 (patch) | |
tree | 1a8418b0c9450ce621dd0c5b3bb65a46326451fd /src/timetype.rs | |
parent | ddc80f3776e2811cd31043f680d90bbde0eafe4b (diff) |
Impl addition/subtraction for reversed arguments
Diffstat (limited to 'src/timetype.rs')
-rw-r--r-- | src/timetype.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/timetype.rs b/src/timetype.rs index 7dda5b5..c40b389 100644 --- a/src/timetype.rs +++ b/src/timetype.rs @@ -68,6 +68,9 @@ fn add(a: Box<TimeType>, b: Box<TimeType>) -> Result<TimeType> { (TT::Addition(a, b), other) => add(a, b) .map(Box::new) .and_then(|bx| add(bx, Box::new(other))), + (other, TT::Addition(a, b)) => add(a, b) + .map(Box::new) + .and_then(|bx| add(Box::new(other), bx)), others => unimplemented!(), } } @@ -86,6 +89,9 @@ fn sub(a: Box<TimeType>, b: Box<TimeType>) -> Result<TimeType> { (TT::Subtraction(a, b), other) => sub(a, b) .map(Box::new) .and_then(|bx| sub(bx, Box::new(other))), + (other, TT::Subtraction(a, b)) => sub(a, b) + .map(Box::new) + .and_then(|bx| sub(Box::new(other), bx)), others => unimplemented!(), } } |