Skip to content

Commit 32168fa

Browse files
author
Jorge Aparicio
committed
libstd: convert BitFlags binops to by value
1 parent baf79d4 commit 32168fa

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/libstd/bitflags.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ macro_rules! bitflags {
209209
}
210210
}
211211

212+
// NOTE(stage0): Remove impl after a snapshot
213+
#[cfg(stage0)]
212214
impl BitOr<$BitFlags, $BitFlags> for $BitFlags {
213215
/// Returns the union of the two sets of flags.
214216
#[inline]
@@ -217,6 +219,17 @@ macro_rules! bitflags {
217219
}
218220
}
219221

222+
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
223+
impl BitOr<$BitFlags, $BitFlags> for $BitFlags {
224+
/// Returns the union of the two sets of flags.
225+
#[inline]
226+
fn bitor(self, other: $BitFlags) -> $BitFlags {
227+
$BitFlags { bits: self.bits | other.bits }
228+
}
229+
}
230+
231+
// NOTE(stage0): Remove impl after a snapshot
232+
#[cfg(stage0)]
220233
impl BitXor<$BitFlags, $BitFlags> for $BitFlags {
221234
/// Returns the left flags, but with all the right flags toggled.
222235
#[inline]
@@ -225,6 +238,17 @@ macro_rules! bitflags {
225238
}
226239
}
227240

241+
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
242+
impl BitXor<$BitFlags, $BitFlags> for $BitFlags {
243+
/// Returns the left flags, but with all the right flags toggled.
244+
#[inline]
245+
fn bitxor(self, other: $BitFlags) -> $BitFlags {
246+
$BitFlags { bits: self.bits ^ other.bits }
247+
}
248+
}
249+
250+
// NOTE(stage0): Remove impl after a snapshot
251+
#[cfg(stage0)]
228252
impl BitAnd<$BitFlags, $BitFlags> for $BitFlags {
229253
/// Returns the intersection between the two sets of flags.
230254
#[inline]
@@ -233,6 +257,17 @@ macro_rules! bitflags {
233257
}
234258
}
235259

260+
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
261+
impl BitAnd<$BitFlags, $BitFlags> for $BitFlags {
262+
/// Returns the intersection between the two sets of flags.
263+
#[inline]
264+
fn bitand(self, other: $BitFlags) -> $BitFlags {
265+
$BitFlags { bits: self.bits & other.bits }
266+
}
267+
}
268+
269+
// NOTE(stage0): Remove impl after a snapshot
270+
#[cfg(stage0)]
236271
impl Sub<$BitFlags, $BitFlags> for $BitFlags {
237272
/// Returns the set difference of the two sets of flags.
238273
#[inline]
@@ -241,6 +276,15 @@ macro_rules! bitflags {
241276
}
242277
}
243278

279+
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
280+
impl Sub<$BitFlags, $BitFlags> for $BitFlags {
281+
/// Returns the set difference of the two sets of flags.
282+
#[inline]
283+
fn sub(self, other: $BitFlags) -> $BitFlags {
284+
$BitFlags { bits: self.bits & !other.bits }
285+
}
286+
}
287+
244288
impl Not<$BitFlags> for $BitFlags {
245289
/// Returns the complement of this set of flags.
246290
#[inline]

0 commit comments

Comments
 (0)