提交 5f347d77 编写于 作者: J Jorge Aparicio

libstd: convert `Duration` unops to by value

上级 340f042e
......@@ -265,6 +265,8 @@ pub fn is_zero(&self) -> bool {
}
}
// NOTE(stage0): Remove impl after a snapshot
#[cfg(stage0)]
impl Neg<Duration> for Duration {
#[inline]
fn neg(&self) -> Duration {
......@@ -276,6 +278,18 @@ fn neg(&self) -> 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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册