Skip to content

Commit 50942c7

Browse files
brsonalexcrichton
authored andcommitted
core: Rename container mod to collections. Closes #12543
Also renames the `Container` trait to `Collection`. [breaking-change]
1 parent 443a1cd commit 50942c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+64
-65
lines changed

src/libcollections/bitv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ impl<S: hash::Writer> hash::Hash<S> for BitvSet {
857857
}
858858
}
859859

860-
impl Container for BitvSet {
860+
impl Collection for BitvSet {
861861
#[inline]
862862
fn len(&self) -> uint { self.size }
863863
}

src/libcollections/dlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn link_with_prev<T>(mut next: Box<Node<T>>, prev: Rawlink<Node<T>>)
125125
Some(next)
126126
}
127127

128-
impl<T> Container for DList<T> {
128+
impl<T> Collection for DList<T> {
129129
/// O(1)
130130
#[inline]
131131
fn is_empty(&self) -> bool {

src/libcollections/priority_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub struct PriorityQueue<T> {
2626
data: Vec<T>,
2727
}
2828

29-
impl<T: Ord> Container for PriorityQueue<T> {
29+
impl<T: Ord> Collection for PriorityQueue<T> {
3030
/// Returns the length of the queue
3131
fn len(&self) -> uint { self.data.len() }
3232
}

src/libcollections/ringbuf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub struct RingBuf<T> {
3333
elts: Vec<Option<T>>
3434
}
3535

36-
impl<T> Container for RingBuf<T> {
36+
impl<T> Collection for RingBuf<T> {
3737
/// Return the number of elements in the RingBuf
3838
fn len(&self) -> uint { self.nelts }
3939
}

src/libcollections/smallintmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub struct SmallIntMap<T> {
2929
v: Vec<Option<T>>,
3030
}
3131

32-
impl<V> Container for SmallIntMap<V> {
32+
impl<V> Collection for SmallIntMap<V> {
3333
/// Return the number of elements in the map
3434
fn len(&self) -> uint {
3535
self.v.iter().filter(|elt| elt.is_some()).count()

src/libcollections/str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ impl<'a> StrAllocating for MaybeOwned<'a> {
610610
}
611611
}
612612

613-
impl<'a> Container for MaybeOwned<'a> {
613+
impl<'a> Collection for MaybeOwned<'a> {
614614
#[inline]
615615
fn len(&self) -> uint { self.as_slice().len() }
616616
}
@@ -2036,7 +2036,7 @@ mod tests {
20362036

20372037
#[test]
20382038
fn test_str_container() {
2039-
fn sum_len<S: Container>(v: &[S]) -> uint {
2039+
fn sum_len<S: Collection>(v: &[S]) -> uint {
20402040
v.iter().map(|x| x.len()).sum()
20412041
}
20422042

src/libcollections/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl String {
279279
}
280280
}
281281

282-
impl Container for String {
282+
impl Collection for String {
283283
#[inline]
284284
fn len(&self) -> uint {
285285
self.vec.len()

src/libcollections/treemap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<K: Ord + Show, V: Show> Show for TreeMap<K, V> {
8686
}
8787
}
8888

89-
impl<K: Ord, V> Container for TreeMap<K, V> {
89+
impl<K: Ord, V> Collection for TreeMap<K, V> {
9090
fn len(&self) -> uint { self.length }
9191
}
9292

@@ -579,7 +579,7 @@ impl<T: Ord + Show> Show for TreeSet<T> {
579579
}
580580
}
581581

582-
impl<T: Ord> Container for TreeSet<T> {
582+
impl<T: Ord> Collection for TreeSet<T> {
583583
#[inline]
584584
fn len(&self) -> uint { self.map.len() }
585585
}

src/libcollections/trie.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub struct TrieMap<T> {
3838
length: uint
3939
}
4040

41-
impl<T> Container for TrieMap<T> {
41+
impl<T> Collection for TrieMap<T> {
4242
/// Return the number of elements in the map
4343
#[inline]
4444
fn len(&self) -> uint { self.length }
@@ -285,7 +285,7 @@ pub struct TrieSet {
285285
map: TrieMap<()>
286286
}
287287

288-
impl Container for TrieSet {
288+
impl Collection for TrieSet {
289289
/// Return the number of elements in the set
290290
#[inline]
291291
fn len(&self) -> uint { self.map.len() }

src/libcollections/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ impl<T: Ord> Ord for Vec<T> {
393393
}
394394
}
395395

396-
impl<T> Container for Vec<T> {
396+
impl<T> Collection for Vec<T> {
397397
#[inline]
398398
fn len(&self) -> uint {
399399
self.len

src/libcore/container.rs renamed to src/libcore/collections.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Traits for generic containers (including `Map` and `Set`)
11+
//! Traits for generic collections (including `Map` and `Set`)
1212
1313
use option::Option;
1414

1515
/// A trait to represent the abstract idea of a container. The only concrete
1616
/// knowledge known is the number of elements contained within.
17-
pub trait Container {
17+
pub trait Collection {
1818
/// Return the number of elements in the container
1919
fn len(&self) -> uint;
2020

@@ -26,14 +26,14 @@ pub trait Container {
2626
}
2727

2828
/// A trait to represent mutable containers
29-
pub trait Mutable: Container {
29+
pub trait Mutable: Collection {
3030
/// Clear the container, removing all values.
3131
fn clear(&mut self);
3232
}
3333

3434
/// A map is a key-value store where values may be looked up by their keys. This
3535
/// trait provides basic operations to operate on these stores.
36-
pub trait Map<K, V>: Container {
36+
pub trait Map<K, V>: Collection {
3737
/// Return a reference to the value corresponding to the key
3838
fn find<'a>(&'a self, key: &K) -> Option<&'a V>;
3939

@@ -76,7 +76,7 @@ pub trait MutableMap<K, V>: Map<K, V> + Mutable {
7676
/// A set is a group of objects which are each distinct from one another. This
7777
/// trait represents actions which can be performed on sets to iterate over
7878
/// them.
79-
pub trait Set<T>: Container {
79+
pub trait Set<T>: Collection {
8080
/// Return true if the set contains a value
8181
fn contains(&self, value: &T) -> bool;
8282

src/libcore/fmt/float.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#![allow(missing_doc)]
1212

1313
use char;
14-
use container::Container;
14+
use collections::Collection;
1515
use fmt;
1616
use iter::{Iterator, range, DoubleEndedIterator};
1717
use num::{Float, FPNaN, FPInfinite, ToPrimitive, Primitive};

src/libcore/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use any;
1616
use cell::Cell;
1717
use char::Char;
18-
use container::Container;
18+
use collections::Collection;
1919
use iter::{Iterator, range};
2020
use kinds::Copy;
2121
use mem;

src/libcore/fmt/num.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#![allow(unsigned_negate)]
1616

17-
use container::Container;
17+
use collections::Collection;
1818
use fmt;
1919
use iter::{Iterator, DoubleEndedIterator};
2020
use num::{Int, cast, zero};

src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub mod ptr;
108108
#[cfg(not(test))] pub mod cmp;
109109
pub mod clone;
110110
pub mod default;
111-
pub mod container;
111+
pub mod collections;
112112

113113
/* Core types and methods on primitives */
114114

src/libcore/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub use char::Char;
4747
pub use clone::Clone;
4848
pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
4949
pub use cmp::{Ordering, Less, Equal, Greater, Equiv};
50-
pub use container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
50+
pub use collections::Collection;
5151
pub use iter::{FromIterator, Extendable};
5252
pub use iter::{Iterator, DoubleEndedIterator, RandomAccessIterator, CloneableIterator};
5353
pub use iter::{OrdIterator, MutableDoubleEndedIterator, ExactSize};

src/libcore/should_not_exist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// Currently, no progress has been made on this list.
2626

2727
use clone::Clone;
28-
use container::Container;
28+
use collections::Collection;
2929
use finally::try_finally;
3030
use intrinsics;
3131
use iter::{range, Iterator};

src/libcore/slice.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
use mem::transmute;
1818
use clone::Clone;
19-
use container::Container;
19+
use collections::Collection;
2020
use cmp::{PartialEq, Ord, Ordering, Less, Equal, Greater};
2121
use cmp;
2222
use default::Default;
@@ -253,7 +253,7 @@ pub mod traits {
253253

254254
use cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering, Equiv};
255255
use iter::order;
256-
use container::Container;
256+
use collections::Collection;
257257

258258
impl<'a,T:PartialEq> PartialEq for &'a [T] {
259259
fn eq(&self, other: & &'a [T]) -> bool {
@@ -347,15 +347,15 @@ impl<T> Vector<T> for ~[T] {
347347
fn as_slice<'a>(&'a self) -> &'a [T] { let v: &'a [T] = *self; v }
348348
}
349349

350-
impl<'a, T> Container for &'a [T] {
350+
impl<'a, T> Collection for &'a [T] {
351351
/// Returns the length of a vector
352352
#[inline]
353353
fn len(&self) -> uint {
354354
self.repr().len
355355
}
356356
}
357357

358-
impl<T> Container for ~[T] {
358+
impl<T> Collection for ~[T] {
359359
/// Returns the length of a vector
360360
#[inline]
361361
fn len(&self) -> uint {
@@ -1205,7 +1205,7 @@ pub mod raw {
12051205

12061206
/// Operations on `[u8]`.
12071207
pub mod bytes {
1208-
use container::Container;
1208+
use collections::Collection;
12091209
use ptr;
12101210
use slice::MutableVector;
12111211

src/libcore/str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use char;
1919
use clone::Clone;
2020
use cmp;
2121
use cmp::{PartialEq, Eq};
22-
use container::Container;
22+
use collections::Collection;
2323
use default::Default;
2424
use iter::{Filter, Map, Iterator};
2525
use iter::{DoubleEndedIterator, ExactSize};
@@ -866,7 +866,7 @@ static TAG_CONT_U8: u8 = 128u8;
866866
/// Unsafe operations
867867
pub mod raw {
868868
use mem;
869-
use container::Container;
869+
use collections::Collection;
870870
use ptr::RawPtr;
871871
use raw::Slice;
872872
use slice::{ImmutableVector};
@@ -930,8 +930,8 @@ Section: Trait implementations
930930
#[cfg(not(test))]
931931
#[allow(missing_doc)]
932932
pub mod traits {
933-
use container::Container;
934933
use cmp::{Ord, Ordering, Less, Equal, Greater, PartialEq, PartialOrd, Equiv, Eq};
934+
use collections::Collection;
935935
use iter::Iterator;
936936
use option::{Some, None};
937937
use str::{Str, StrSlice, eq_slice};
@@ -987,7 +987,7 @@ impl<'a> Str for &'a str {
987987
fn as_slice<'a>(&'a self) -> &'a str { *self }
988988
}
989989

990-
impl<'a> Container for &'a str {
990+
impl<'a> Collection for &'a str {
991991
#[inline]
992992
fn len(&self) -> uint {
993993
self.repr().len

src/libregex/re.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ impl<'t> Captures<'t> {
775775
}
776776
}
777777

778-
impl<'t> Container for Captures<'t> {
778+
impl<'t> Collection for Captures<'t> {
779779
/// Returns the number of captured groups.
780780
#[inline]
781781
fn len(&self) -> uint {

src/librustc/middle/trans/adt.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545

4646
#![allow(unsigned_negate)]
4747

48-
use std::container::Map;
4948
use libc::c_ulonglong;
5049
use std::num::{Bitwise};
5150
use std::rc::Rc;

src/librustrt/c_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl Drop for CString {
229229
}
230230
}
231231

232-
impl Container for CString {
232+
impl Collection for CString {
233233
/// Return the number of bytes in the CString (not including the NUL terminator).
234234
///
235235
/// # Failure

src/libstd/ascii.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! Operations on ASCII strings and characters
1212
13-
use container::Container;
13+
use collections::Collection;
1414
use fmt;
1515
use iter::Iterator;
1616
use mem;

src/libstd/c_vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
//! handled correctly, i.e. that allocated memory is eventually freed
3434
//! if necessary.
3535
36-
use container::Container;
36+
use collections::Collection;
3737
use kinds::Send;
3838
use mem;
3939
use ops::Drop;
@@ -149,7 +149,7 @@ impl<T> CVec<T> {
149149
}
150150
}
151151

152-
impl<T> Container for CVec<T> {
152+
impl<T> Collection for CVec<T> {
153153
fn len(&self) -> uint { self.len }
154154
}
155155

src/libstd/collections/hashmap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> PartialEq for HashSet<T, H> {
15041504

15051505
impl<T: Eq + Hash<S>, S, H: Hasher<S>> Eq for HashSet<T, H> {}
15061506

1507-
impl<T: Eq + Hash<S>, S, H: Hasher<S>> Container for HashSet<T, H> {
1507+
impl<T: Eq + Hash<S>, S, H: Hasher<S>> Collection for HashSet<T, H> {
15081508
fn len(&self) -> uint { self.map.len() }
15091509
}
15101510

@@ -2159,8 +2159,8 @@ mod test_set {
21592159
use prelude::*;
21602160

21612161
use super::HashSet;
2162-
use container::Container;
21632162
use slice::ImmutableEqVector;
2163+
use std::collections::Collection;
21642164

21652165
#[test]
21662166
fn test_disjoint() {

src/libstd/collections/lru_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl<A: fmt::Show + Hash + Eq, B: fmt::Show> fmt::Show for LruCache<A, B> {
227227
}
228228
}
229229

230-
impl<K: Hash + Eq, V> Container for LruCache<K, V> {
230+
impl<K: Hash + Eq, V> Collection for LruCache<K, V> {
231231
/// Return the number of key-value pairs in the cache.
232232
fn len(&self) -> uint {
233233
self.map.len()

src/libstd/comm/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
/// of a synchronous channel. There are a few branches for the unbuffered case,
3434
/// but they're mostly just relevant to blocking senders.
3535
36-
use container::Container;
36+
use collections::Collection;
3737
use iter::Iterator;
3838
use kinds::Send;
3939
use mem;

src/libstd/io/buffered.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! Buffering wrappers for I/O traits
1212
1313
use cmp;
14-
use container::Container;
14+
use collections::Collection;
1515
use io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult};
1616
use iter::ExactSize;
1717
use ops::Drop;

0 commit comments

Comments
 (0)