libstd: convert `Duration` unops to by value
This commit is contained in:
parent
340f042e03
commit
5f347d7708
|
@ -265,6 +265,8 @@ impl Duration {
|
|||
}
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove impl after a snapshot
|
||||
#[cfg(stage0)]
|
||||
impl Neg<Duration> for Duration {
|
||||
#[inline]
|
||||
fn neg(&self) -> Duration {
|
||||
|
@ -276,6 +278,18 @@ impl Neg<Duration> for Duration {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
|
||||
impl Neg<Duration> 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<Duration,Duration> for Duration {
|
||||
|
|
Loading…
Reference in New Issue