From 5f347d77084d873d213ca1aa29ccfd8fdd27e28a Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 15 Dec 2014 17:06:34 -0500 Subject: [PATCH] libstd: convert `Duration` unops to by value --- src/libstd/time/duration.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs index 8c4a5a6b8c7f..85ed27853c45 100644 --- a/src/libstd/time/duration.rs +++ b/src/libstd/time/duration.rs @@ -265,6 +265,8 @@ impl Duration { } } +// NOTE(stage0): Remove impl after a snapshot +#[cfg(stage0)] impl Neg for Duration { #[inline] fn neg(&self) -> Duration { @@ -276,6 +278,18 @@ impl Neg for Duration { } } +#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot +impl Neg for Duration { + #[inline] + fn neg(self) -> Duration { + if self.nanos == 0 { + Duration { secs: -self.secs, nanos: 0 } + } else { + Duration { secs: -self.secs - 1, nanos: NANOS_PER_SEC - self.nanos } + } + } +} + // NOTE(stage0): Remove impl after a snapshot #[cfg(stage0)] impl Add for Duration {