Skip to content

Commit baf79d4

Browse files
author
Jorge Aparicio
committed
libcollections: make EnumSet binops by value
1 parent 076e932 commit baf79d4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/libcollections/enum_set.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,30 +183,66 @@ impl<E:CLike> EnumSet<E> {
183183
}
184184
}
185185

186+
// NOTE(stage0): Remove impl after a snapshot
187+
#[cfg(stage0)]
186188
impl<E:CLike> Sub<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
187189
fn sub(&self, e: &EnumSet<E>) -> EnumSet<E> {
188190
EnumSet {bits: self.bits & !e.bits}
189191
}
190192
}
191193

194+
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
195+
impl<E:CLike> Sub<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
196+
fn sub(self, e: EnumSet<E>) -> EnumSet<E> {
197+
EnumSet {bits: self.bits & !e.bits}
198+
}
199+
}
200+
201+
// NOTE(stage0): Remove impl after a snapshot
202+
#[cfg(stage0)]
192203
impl<E:CLike> BitOr<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
193204
fn bitor(&self, e: &EnumSet<E>) -> EnumSet<E> {
194205
EnumSet {bits: self.bits | e.bits}
195206
}
196207
}
197208

209+
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
210+
impl<E:CLike> BitOr<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
211+
fn bitor(self, e: EnumSet<E>) -> EnumSet<E> {
212+
EnumSet {bits: self.bits | e.bits}
213+
}
214+
}
215+
216+
// NOTE(stage0): Remove impl after a snapshot
217+
#[cfg(stage0)]
198218
impl<E:CLike> BitAnd<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
199219
fn bitand(&self, e: &EnumSet<E>) -> EnumSet<E> {
200220
EnumSet {bits: self.bits & e.bits}
201221
}
202222
}
203223

224+
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
225+
impl<E:CLike> BitAnd<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
226+
fn bitand(self, e: EnumSet<E>) -> EnumSet<E> {
227+
EnumSet {bits: self.bits & e.bits}
228+
}
229+
}
230+
231+
// NOTE(stage0): Remove impl after a snapshot
232+
#[cfg(stage0)]
204233
impl<E:CLike> BitXor<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
205234
fn bitxor(&self, e: &EnumSet<E>) -> EnumSet<E> {
206235
EnumSet {bits: self.bits ^ e.bits}
207236
}
208237
}
209238

239+
#[cfg(not(stage0))] // NOTE(stage0): Remove cfg after a snapshot
240+
impl<E:CLike> BitXor<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
241+
fn bitxor(self, e: EnumSet<E>) -> EnumSet<E> {
242+
EnumSet {bits: self.bits ^ e.bits}
243+
}
244+
}
245+
210246
/// An iterator over an EnumSet
211247
pub struct Items<E> {
212248
index: uint,

0 commit comments

Comments
 (0)