Skip to content

Commit 8ad7e54

Browse files
committed
collections: Switch field privacy as necessary
1 parent 9a3d04a commit 8ad7e54

File tree

12 files changed

+112
-110
lines changed

12 files changed

+112
-110
lines changed

src/libcollections/bitv.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ enum Op {Union, Intersect, Assign, Difference}
227227
#[deriving(Clone)]
228228
pub struct Bitv {
229229
/// Internal representation of the bit vector (small or large)
230-
priv rep: BitvVariant,
230+
rep: BitvVariant,
231231
/// The number of valid bits in the internal representation
232-
priv nbits: uint
232+
nbits: uint
233233
}
234234

235235
fn die() -> ! {
@@ -587,9 +587,9 @@ fn iterate_bits(base: uint, bits: uint, f: |uint| -> bool) -> bool {
587587

588588
/// An iterator for `Bitv`.
589589
pub struct Bits<'a> {
590-
priv bitv: &'a Bitv,
591-
priv next_idx: uint,
592-
priv end_idx: uint,
590+
bitv: &'a Bitv,
591+
next_idx: uint,
592+
end_idx: uint,
593593
}
594594

595595
impl<'a> Iterator<bool> for Bits<'a> {
@@ -648,12 +648,12 @@ impl<'a> RandomAccessIterator<bool> for Bits<'a> {
648648
/// as a `uint`.
649649
#[deriving(Clone)]
650650
pub struct BitvSet {
651-
priv size: uint,
651+
size: uint,
652652

653653
// In theory this is a `Bitv` instead of always a `BigBitv`, but knowing that
654654
// there's an array of storage makes our lives a whole lot easier when
655655
// performing union/intersection/etc operations
656-
priv bitv: BigBitv
656+
bitv: BigBitv
657657
}
658658

659659
impl BitvSet {
@@ -912,8 +912,8 @@ impl BitvSet {
912912
}
913913

914914
pub struct BitPositions<'a> {
915-
priv set: &'a BitvSet,
916-
priv next_idx: uint
915+
set: &'a BitvSet,
916+
next_idx: uint
917917
}
918918

919919
impl<'a> Iterator<uint> for BitPositions<'a> {

src/libcollections/btree.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ use std::fmt::Show;
2323

2424
#[allow(missing_doc)]
2525
pub struct BTree<K, V> {
26-
priv root: Node<K, V>,
27-
priv len: uint,
28-
priv lower_bound: uint,
29-
priv upper_bound: uint
26+
root: Node<K, V>,
27+
len: uint,
28+
lower_bound: uint,
29+
upper_bound: uint
3030
}
3131

3232
impl<K: TotalOrd, V> BTree<K, V> {

src/libcollections/dlist.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ use deque::Deque;
3232

3333
/// A doubly-linked list.
3434
pub struct DList<T> {
35-
priv length: uint,
36-
priv list_head: Link<T>,
37-
priv list_tail: Rawlink<Node<T>>,
35+
length: uint,
36+
list_head: Link<T>,
37+
list_tail: Rawlink<Node<T>>,
3838
}
3939

4040
type Link<T> = Option<~Node<T>>;
@@ -48,9 +48,9 @@ struct Node<T> {
4848

4949
/// Double-ended DList iterator
5050
pub struct Items<'a, T> {
51-
priv head: &'a Link<T>,
52-
priv tail: Rawlink<Node<T>>,
53-
priv nelem: uint,
51+
head: &'a Link<T>,
52+
tail: Rawlink<Node<T>>,
53+
nelem: uint,
5454
}
5555

5656
// FIXME #11820: the &'a Option<> of the Link stops clone working.
@@ -60,16 +60,16 @@ impl<'a, T> Clone for Items<'a, T> {
6060

6161
/// Double-ended mutable DList iterator
6262
pub struct MutItems<'a, T> {
63-
priv list: &'a mut DList<T>,
64-
priv head: Rawlink<Node<T>>,
65-
priv tail: Rawlink<Node<T>>,
66-
priv nelem: uint,
63+
list: &'a mut DList<T>,
64+
head: Rawlink<Node<T>>,
65+
tail: Rawlink<Node<T>>,
66+
nelem: uint,
6767
}
6868

6969
/// DList consuming iterator
7070
#[deriving(Clone)]
7171
pub struct MoveItems<T> {
72-
priv list: DList<T>
72+
list: DList<T>
7373
}
7474

7575
/// Rawlink is a type like Option<T> but for holding a raw pointer

src/libcollections/enum_set.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::num::Bitwise;
2020
pub struct EnumSet<E> {
2121
// We must maintain the invariant that no bits are set
2222
// for which no variant exists
23-
priv bits: uint
23+
bits: uint
2424
}
2525

2626
/// An interface for casting C-like enum to uint and back.
@@ -102,8 +102,8 @@ impl<E:CLike> BitAnd<EnumSet<E>, EnumSet<E>> for EnumSet<E> {
102102

103103
/// An iterator over an EnumSet
104104
pub struct Items<E> {
105-
priv index: uint,
106-
priv bits: uint,
105+
index: uint,
106+
bits: uint,
107107
}
108108

109109
impl<E:CLike> Items<E> {

src/libcollections/hashmap.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,25 @@ mod table {
100100
/// this and going "what? of course there are debug-only asserts!", then
101101
/// please make this use them!
102102
pub struct RawTable<K, V> {
103-
priv capacity: uint,
104-
priv size: uint,
105-
priv hashes: *mut u64,
106-
priv keys: *mut K,
107-
priv vals: *mut V,
103+
capacity: uint,
104+
size: uint,
105+
hashes: *mut u64,
106+
keys: *mut K,
107+
vals: *mut V,
108108
}
109109

110110
/// Represents an index into a `RawTable` with no key or value in it.
111111
pub struct EmptyIndex {
112-
priv idx: int,
113-
priv nocopy: marker::NoCopy,
112+
idx: int,
113+
nocopy: marker::NoCopy,
114114
}
115115

116116
/// Represents an index into a `RawTable` with a key, value, and hash
117117
/// in it.
118118
pub struct FullIndex {
119-
priv idx: int,
120-
priv hash: SafeHash,
121-
priv nocopy: marker::NoCopy,
119+
idx: int,
120+
hash: SafeHash,
121+
nocopy: marker::NoCopy,
122122
}
123123

124124
impl FullIndex {
@@ -142,7 +142,7 @@ mod table {
142142
/// A hash that is not zero, since we use that to represent empty buckets.
143143
#[deriving(Eq)]
144144
pub struct SafeHash {
145-
priv hash: u64,
145+
hash: u64,
146146
}
147147

148148
impl SafeHash {
@@ -376,18 +376,18 @@ mod table {
376376
}
377377

378378
pub struct Entries<'a, K, V> {
379-
priv table: &'a RawTable<K, V>,
380-
priv idx: uint,
379+
table: &'a RawTable<K, V>,
380+
idx: uint,
381381
}
382382

383383
pub struct MutEntries<'a, K, V> {
384-
priv table: &'a mut RawTable<K, V>,
385-
priv idx: uint,
384+
table: &'a mut RawTable<K, V>,
385+
idx: uint,
386386
}
387387

388388
pub struct MoveEntries<K, V> {
389-
priv table: RawTable<K, V>,
390-
priv idx: uint,
389+
table: RawTable<K, V>,
390+
idx: uint,
391391
}
392392

393393
impl<'a, K, V> Iterator<(&'a K, &'a V)> for Entries<'a, K, V> {
@@ -675,19 +675,19 @@ static INITIAL_LOAD_FACTOR: Fraction = (9, 10);
675675
#[deriving(Clone)]
676676
pub struct HashMap<K, V, H = sip::SipHasher> {
677677
// All hashes are keyed on these values, to prevent hash collision attacks.
678-
priv hasher: H,
678+
hasher: H,
679679

680680
// When size == grow_at, we double the capacity.
681-
priv grow_at: uint,
681+
grow_at: uint,
682682

683683
// The capacity must never drop below this.
684-
priv minimum_capacity: uint,
684+
minimum_capacity: uint,
685685

686-
priv table: table::RawTable<K, V>,
686+
table: table::RawTable<K, V>,
687687

688688
// We keep this at the end since it's 4-bytes, unlike everything else
689689
// in this struct. Might as well save a word of padding!
690-
priv load_factor: Fraction,
690+
load_factor: Fraction,
691691
}
692692

693693
/// Get the number of elements which will force the capacity to grow.
@@ -1385,7 +1385,7 @@ pub type SetMoveItems<K> =
13851385
/// requires that the elements implement the `Eq` and `Hash` traits.
13861386
#[deriving(Clone)]
13871387
pub struct HashSet<T, H = sip::SipHasher> {
1388-
priv map: HashMap<T, (), H>
1388+
map: HashMap<T, (), H>
13891389
}
13901390

13911391
impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Eq for HashSet<T, H> {

src/libcollections/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
#![feature(macro_rules, managed_boxes, default_type_params, phase)]
2424

25+
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
26+
2527
extern crate rand;
2628

2729
#[cfg(test)] extern crate test;

src/libcollections/lru_cache.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ struct LruEntry<K, V> {
5656

5757
/// An LRU Cache.
5858
pub struct LruCache<K, V> {
59-
priv map: HashMap<KeyRef<K>, ~LruEntry<K, V>>,
60-
priv max_size: uint,
61-
priv head: *mut LruEntry<K, V>,
62-
priv tail: *mut LruEntry<K, V>,
59+
map: HashMap<KeyRef<K>, ~LruEntry<K, V>>,
60+
max_size: uint,
61+
head: *mut LruEntry<K, V>,
62+
tail: *mut LruEntry<K, V>,
6363
}
6464

6565
impl<S, K: Hash<S>> Hash<S> for KeyRef<K> {

src/libcollections/priority_queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::slice;
1919
/// A priority queue implemented with a binary heap
2020
#[deriving(Clone)]
2121
pub struct PriorityQueue<T> {
22-
priv data: ~[T],
22+
data: ~[T],
2323
}
2424

2525
impl<T:Ord> Container for PriorityQueue<T> {
@@ -181,7 +181,7 @@ impl<T:Ord> PriorityQueue<T> {
181181

182182
/// PriorityQueue iterator
183183
pub struct Items <'a, T> {
184-
priv iter: slice::Items<'a, T>,
184+
iter: slice::Items<'a, T>,
185185
}
186186

187187
impl<'a, T> Iterator<&'a T> for Items<'a, T> {

src/libcollections/ringbuf.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ static MINIMUM_CAPACITY: uint = 2u;
2525
/// RingBuf is a circular buffer that implements Deque.
2626
#[deriving(Clone)]
2727
pub struct RingBuf<T> {
28-
priv nelts: uint,
29-
priv lo: uint,
30-
priv elts: ~[Option<T>]
28+
nelts: uint,
29+
lo: uint,
30+
elts: ~[Option<T>]
3131
}
3232

3333
impl<T> Container for RingBuf<T> {
@@ -230,10 +230,10 @@ impl<T> RingBuf<T> {
230230

231231
/// RingBuf iterator
232232
pub struct Items<'a, T> {
233-
priv lo: uint,
234-
priv index: uint,
235-
priv rindex: uint,
236-
priv elts: &'a [Option<T>],
233+
lo: uint,
234+
index: uint,
235+
rindex: uint,
236+
elts: &'a [Option<T>],
237237
}
238238

239239
impl<'a, T> Iterator<&'a T> for Items<'a, T> {
@@ -285,9 +285,9 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> {
285285

286286
/// RingBuf mutable iterator
287287
pub struct MutItems<'a, T> {
288-
priv remaining1: &'a mut [Option<T>],
289-
priv remaining2: &'a mut [Option<T>],
290-
priv nelts: uint,
288+
remaining1: &'a mut [Option<T>],
289+
remaining2: &'a mut [Option<T>],
290+
nelts: uint,
291291
}
292292

293293
impl<'a, T> Iterator<&'a mut T> for MutItems<'a, T> {

src/libcollections/smallintmap.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::slice;
2121

2222
#[allow(missing_doc)]
2323
pub struct SmallIntMap<T> {
24-
priv v: ~[Option<T>],
24+
v: ~[Option<T>],
2525
}
2626

2727
impl<V> Container for SmallIntMap<V> {
@@ -234,19 +234,19 @@ macro_rules! double_ended_iterator {
234234
}
235235

236236
pub struct Entries<'a, T> {
237-
priv front: uint,
238-
priv back: uint,
239-
priv iter: slice::Items<'a, Option<T>>
237+
front: uint,
238+
back: uint,
239+
iter: slice::Items<'a, Option<T>>
240240
}
241241

242242
iterator!(impl Entries -> (uint, &'a T), get_ref)
243243
double_ended_iterator!(impl Entries -> (uint, &'a T), get_ref)
244244
pub type RevEntries<'a, T> = Rev<Entries<'a, T>>;
245245

246246
pub struct MutEntries<'a, T> {
247-
priv front: uint,
248-
priv back: uint,
249-
priv iter: slice::MutItems<'a, Option<T>>
247+
front: uint,
248+
back: uint,
249+
iter: slice::MutItems<'a, Option<T>>
250250
}
251251

252252
iterator!(impl MutEntries -> (uint, &'a mut T), get_mut_ref)

0 commit comments

Comments
 (0)