mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 21:15:18 +03:00
libstd: convert Duration unops to by value
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user