From 19466e6ff4e4477f4debc170814f2b7470fca8c3 Mon Sep 17 00:00:00 2001 From: Toby Dimmick Date: Tue, 3 Apr 2018 14:16:37 +0100 Subject: [PATCH] Move `SubAssign next to `Sub for NaiveDate { } } +impl SubAssign for NaiveDate { + #[inline] + fn sub_assign(&mut self, rhs: OldDuration) { + *self = self.sub(rhs); + } +} + /// Subtracts another `NaiveDate` from the current date. /// Returns a `Duration` of integral numbers. /// @@ -1414,13 +1421,6 @@ impl Sub for NaiveDate { } } -impl SubAssign for NaiveDate { - #[inline] - fn sub_assign(&mut self, rhs: OldDuration) { - *self = self.sub(rhs); - } -} - /// The `Debug` output of the naive date `d` is same to /// [`d.format("%Y-%m-%d")`](../format/strftime/index.html). /// diff --git a/src/naive/datetime.rs b/src/naive/datetime.rs index 3c761f7..46ec0d3 100644 --- a/src/naive/datetime.rs +++ b/src/naive/datetime.rs @@ -1272,6 +1272,13 @@ impl Sub for NaiveDateTime { } } +impl SubAssign for NaiveDateTime { + #[inline] + fn sub_assign(&mut self, rhs: OldDuration) { + *self = self.sub(rhs); + } +} + /// Subtracts another `NaiveDateTime` from the current date and time. /// This does not overflow or underflow at all. /// @@ -1327,13 +1334,6 @@ impl Sub for NaiveDateTime { } } -impl SubAssign for NaiveDateTime { - #[inline] - fn sub_assign(&mut self, rhs: OldDuration) { - *self = self.sub(rhs); - } -} - /// The `Debug` output of the naive date and time `dt` is same to /// [`dt.format("%Y-%m-%dT%H:%M:%S%.f")`](../format/strftime/index.html). /// diff --git a/src/naive/time.rs b/src/naive/time.rs index 73e1c3e..440c8a7 100644 --- a/src/naive/time.rs +++ b/src/naive/time.rs @@ -1126,6 +1126,13 @@ impl Sub for NaiveTime { } } +impl SubAssign for NaiveTime { + #[inline] + fn sub_assign(&mut self, rhs: OldDuration) { + *self = self.sub(rhs); + } +} + /// Subtracts another `NaiveTime` from the current time. /// Returns a `Duration` within +/- 1 day. /// This does not overflow or underflow at all. @@ -1186,13 +1193,6 @@ impl Sub for NaiveTime { } } -impl SubAssign for NaiveTime { - #[inline] - fn sub_assign(&mut self, rhs: OldDuration) { - *self = self.sub(rhs); - } -} - /// The `Debug` output of the naive time `t` is same to /// [`t.format("%H:%M:%S%.f")`](../format/strftime/index.html). ///