Skip to content

Commit 8529721

Browse files
committed
---
yaml --- r: 183927 b: refs/heads/master c: c2891cc h: refs/heads/master i: 183925: 97c98d8 183923: ab4060b 183919: 283ffc1 v: v3
1 parent fe04e42 commit 8529721

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 68ebe640b6c99f53fee53671e09c673c8c17726a
2+
refs/heads/master: c2891cc48798908a96d1b3f847d2cf241fcc58bb
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
55
refs/heads/try: ccf8fedf1cffcb8f6f3581d53d220039e192fe77

trunk/src/libcollections/enum_set.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//! representation to hold C-like enum variants.
1515
1616
use core::prelude::*;
17+
use core::marker;
1718
use core::fmt;
1819
use core::num::Int;
1920
use core::iter::{FromIterator, IntoIterator};
@@ -26,7 +27,8 @@ use core::ops::{Sub, BitOr, BitAnd, BitXor};
2627
pub struct EnumSet<E> {
2728
// We must maintain the invariant that no bits are set
2829
// for which no variant exists
29-
bits: usize
30+
bits: usize,
31+
marker: marker::PhantomData<E>,
3032
}
3133

3234
impl<E> Copy for EnumSet<E> {}
@@ -86,7 +88,7 @@ impl<E:CLike> EnumSet<E> {
8688
#[unstable(feature = "collections",
8789
reason = "matches collection reform specification, waiting for dust to settle")]
8890
pub fn new() -> EnumSet<E> {
89-
EnumSet {bits: 0}
91+
EnumSet {bits: 0, marker: marker::PhantomData}
9092
}
9193

9294
/// Returns the number of elements in the given `EnumSet`.
@@ -130,12 +132,14 @@ impl<E:CLike> EnumSet<E> {
130132

131133
/// Returns the union of both `EnumSets`.
132134
pub fn union(&self, e: EnumSet<E>) -> EnumSet<E> {
133-
EnumSet {bits: self.bits | e.bits}
135+
EnumSet {bits: self.bits | e.bits,
136+
marker: marker::PhantomData}
134137
}
135138

136139
/// Returns the intersection of both `EnumSets`.
137140
pub fn intersection(&self, e: EnumSet<E>) -> EnumSet<E> {
138-
EnumSet {bits: self.bits & e.bits}
141+
EnumSet {bits: self.bits & e.bits,
142+
marker: marker::PhantomData}
139143
}
140144

141145
/// Adds an enum to the `EnumSet`, and returns `true` if it wasn't there before
@@ -175,38 +179,39 @@ impl<E:CLike> Sub for EnumSet<E> {
175179
type Output = EnumSet<E>;
176180

177181
fn sub(self, e: EnumSet<E>) -> EnumSet<E> {
178-
EnumSet {bits: self.bits & !e.bits}
182+
EnumSet {bits: self.bits & !e.bits, marker: marker::PhantomData}
179183
}
180184
}
181185

182186
impl<E:CLike> BitOr for EnumSet<E> {
183187
type Output = EnumSet<E>;
184188

185189
fn bitor(self, e: EnumSet<E>) -> EnumSet<E> {
186-
EnumSet {bits: self.bits | e.bits}
190+
EnumSet {bits: self.bits | e.bits, marker: marker::PhantomData}
187191
}
188192
}
189193

190194
impl<E:CLike> BitAnd for EnumSet<E> {
191195
type Output = EnumSet<E>;
192196

193197
fn bitand(self, e: EnumSet<E>) -> EnumSet<E> {
194-
EnumSet {bits: self.bits & e.bits}
198+
EnumSet {bits: self.bits & e.bits, marker: marker::PhantomData}
195199
}
196200
}
197201

198202
impl<E:CLike> BitXor for EnumSet<E> {
199203
type Output = EnumSet<E>;
200204

201205
fn bitxor(self, e: EnumSet<E>) -> EnumSet<E> {
202-
EnumSet {bits: self.bits ^ e.bits}
206+
EnumSet {bits: self.bits ^ e.bits, marker: marker::PhantomData}
203207
}
204208
}
205209

206210
/// An iterator over an EnumSet
207211
pub struct Iter<E> {
208212
index: usize,
209213
bits: usize,
214+
marker: marker::PhantomData<E>,
210215
}
211216

212217
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
@@ -215,13 +220,14 @@ impl<E> Clone for Iter<E> {
215220
Iter {
216221
index: self.index,
217222
bits: self.bits,
223+
marker: marker::PhantomData,
218224
}
219225
}
220226
}
221227

222228
impl<E:CLike> Iter<E> {
223229
fn new(bits: usize) -> Iter<E> {
224-
Iter { index: 0, bits: bits }
230+
Iter { index: 0, bits: bits, marker: marker::PhantomData }
225231
}
226232
}
227233

0 commit comments

Comments
 (0)