From 340f042e03f6c50f229a8e21a93af22485d725f2 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 15 Dec 2014 17:06:10 -0500 Subject: libstd: convert `BitFlags` unops to by value --- src/libstd/bitflags.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/libstd') diff --git a/src/libstd/bitflags.rs b/src/libstd/bitflags.rs index 2be6f5057a1..f467b77dbf4 100644 --- a/src/libstd/bitflags.rs +++ b/src/libstd/bitflags.rs @@ -281,6 +281,8 @@ macro_rules! bitflags { } } + // NOTE(stage0): Remove impl after a snapshot + #[cfg(stage0)] impl Not<$BitFlags> for $BitFlags { /// Returns the complement of this set of flags. #[inline] @@ -288,6 +290,15 @@ macro_rules! bitflags { $BitFlags { bits: !self.bits } & $BitFlags::all() } } + + #[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot + impl Not<$BitFlags> for $BitFlags { + /// Returns the complement of this set of flags. + #[inline] + fn not(self) -> $BitFlags { + $BitFlags { bits: !self.bits } & $BitFlags::all() + } + } }; ($(#[$attr:meta])* flags $BitFlags:ident: $T:ty { $($(#[$Flag_attr:meta])* const $Flag:ident = $value:expr),+, -- cgit 1.4.1-3-g733a5 From 5f347d77084d873d213ca1aa29ccfd8fdd27e28a Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 15 Dec 2014 17:06:34 -0500 Subject: libstd: convert `Duration` unops to by value --- src/libstd/time/duration.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/libstd') diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs index 8c4a5a6b8c7..85ed27853c4 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 { -- cgit 1.4.1-3-g733a5