Skip to content

Commit d81bb44

Browse files
committed
moved collections from libextra into libcollections
1 parent 87fe3cc commit d81bb44

36 files changed

+117
-72
lines changed

mk/crates.mk

+8-6
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,30 @@
5050
################################################################################
5151

5252
TARGET_CRATES := std extra green rustuv native flate arena glob term semver \
53-
uuid serialize sync getopts
53+
uuid serialize sync getopts collections
5454
HOST_CRATES := syntax rustc rustdoc
5555
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5656
TOOLS := compiletest rustdoc rustc
5757

5858
DEPS_std := native:rustrt
59-
DEPS_extra := std term sync serialize getopts
59+
DEPS_extra := std term sync serialize getopts collections
6060
DEPS_green := std
6161
DEPS_rustuv := std native:uv native:uv_support
6262
DEPS_native := std
63-
DEPS_syntax := std extra term serialize
64-
DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts
65-
DEPS_rustdoc := rustc native:sundown serialize sync getopts
63+
DEPS_syntax := std extra term serialize collections
64+
DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts \
65+
collections
66+
DEPS_rustdoc := rustc native:sundown serialize sync getopts collections
6667
DEPS_flate := std native:miniz
67-
DEPS_arena := std extra
68+
DEPS_arena := std collections
6869
DEPS_glob := std
6970
DEPS_serialize := std
7071
DEPS_term := std
7172
DEPS_semver := std
7273
DEPS_uuid := std serialize
7374
DEPS_sync := std
7475
DEPS_getopts := std
76+
DEPS_collections := std serialize
7577

7678
TOOL_DEPS_compiletest := extra green rustuv getopts
7779
TOOL_DEPS_rustdoc := rustdoc green rustuv

src/doc/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ li {list-style-type: none; }
3838
* [The Rust compiler, `librustc`](rustc/index.html)
3939

4040
* [The `arena` allocation library](arena/index.html)
41+
* [The `collections` library](collections/index.html)
4142
* [The `flate` compression library](flate/index.html)
4243
* [The `getopts` argument parsing library](getopts/index.html)
4344
* [The `glob` file path matching library](glob/index.html)

src/doc/rust.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ use foo::baz::foobaz; // good: foo is at the root of the crate
881881
mod foo {
882882
extern mod extra;
883883
884-
use foo::extra::list; // good: foo is at crate root
884+
use foo::extra::time; // good: foo is at crate root
885885
// use extra::*; // bad: extra is not at the crate root
886886
use self::baz::foobaz; // good: self refers to module 'foo'
887887
use foo::bar::foobar; // good: foo is at crate root

src/libarena/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
#[allow(missing_doc)];
2323
#[feature(managed_boxes)];
2424

25-
extern mod extra;
25+
extern mod collections;
2626

27-
use extra::list::{List, Cons, Nil};
28-
use extra::list;
27+
#[cfg(test)] extern mod extra;
28+
29+
use collections::list::{List, Cons, Nil};
30+
use collections::list;
2931

3032
use std::cast::{transmute, transmute_mut, transmute_mut_region};
3133
use std::cast;
File renamed without changes.
File renamed without changes.

src/libextra/container.rs renamed to src/libcollections/deque.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub mod bench {
4444
use std::container::MutableMap;
4545
use std::{vec, rand};
4646
use std::rand::Rng;
47-
use test::BenchHarness;
47+
use extra::test::BenchHarness;
4848

4949
pub fn insert_rand_n<M:MutableMap<uint,uint>>(n: uint,
5050
map: &mut M,

src/libextra/dlist.rs renamed to src/libcollections/dlist.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use std::util;
2828
use std::iter::Rev;
2929
use std::iter;
3030

31-
use container::Deque;
31+
use deque::Deque;
3232

3333
use serialize::{Encodable, Decodable, Encoder, Decoder};
3434

@@ -657,7 +657,7 @@ impl<D:Decoder,T:Decodable<D>> Decodable<D> for DList<T> {
657657

658658
#[cfg(test)]
659659
mod tests {
660-
use container::Deque;
660+
use deque::Deque;
661661
use extra::test;
662662
use std::rand;
663663
use super::{DList, Node, ListInsertion};

src/libcollections/lib.rs

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
/*!
12+
* Collection types.
13+
*/
14+
15+
#[crate_id = "collections#0.10-pre"];
16+
#[crate_type = "rlib"];
17+
#[crate_type = "dylib"];
18+
#[license = "MIT/ASL2"];
19+
20+
#[feature(macro_rules, managed_boxes)];
21+
22+
#[cfg(test)] extern mod extra;
23+
24+
extern mod serialize;
25+
26+
pub use bitv::Bitv;
27+
pub use btree::BTree;
28+
pub use deque::Deque;
29+
pub use dlist::DList;
30+
pub use list::List;
31+
pub use lru_cache::LruCache;
32+
pub use priority_queue::PriorityQueue;
33+
pub use ringbuf::RingBuf;
34+
pub use smallintmap::SmallIntMap;
35+
pub use treemap::{TreeMap, TreeSet};
36+
37+
pub mod bitv;
38+
pub mod btree;
39+
pub mod deque;
40+
pub mod dlist;
41+
pub mod list;
42+
pub mod lru_cache;
43+
pub mod priority_queue;
44+
pub mod ringbuf;
45+
pub mod smallintmap;
46+
pub mod treemap;

src/libextra/list.rs renamed to src/libcollections/list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ pub fn each<T>(l: @List<T>, f: |&T| -> bool) -> bool {
153153

154154
#[cfg(test)]
155155
mod tests {
156-
use list::*;
156+
use list::{List, Nil, from_vec, head, is_empty, tail};
157157
use list;
158158

159159
use std::option;

src/libextra/lru_cache.rs renamed to src/libcollections/lru_cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//! # Example
1818
//!
1919
//! ```rust
20-
//! use extra::lru_cache::LruCache;
20+
//! use collections::LruCache;
2121
//!
2222
//! let mut cache: LruCache<int, int> = LruCache::new(2);
2323
//! cache.put(1, 10);
File renamed without changes.

src/libextra/ringbuf.rs renamed to src/libcollections/ringbuf.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::num;
1717
use std::vec;
1818
use std::iter::{Rev, RandomAccessIterator};
1919

20-
use container::Deque;
20+
use deque::Deque;
2121

2222
use serialize::{Encodable, Decodable, Encoder, Decoder};
2323

@@ -431,7 +431,7 @@ impl<D:Decoder,T:Decodable<D>> Decodable<D> for RingBuf<T> {
431431

432432
#[cfg(test)]
433433
mod tests {
434-
use container::Deque;
434+
use deque::Deque;
435435
use extra::test;
436436
use std::clone::Clone;
437437
use std::cmp::Eq;

src/libextra/smallintmap.rs renamed to src/libcollections/smallintmap.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,9 @@ mod test_map {
471471
#[cfg(test)]
472472
mod bench {
473473

474-
use super::*;
475-
use test::BenchHarness;
476-
use container::bench::*;
474+
use super::SmallIntMap;
475+
use extra::test::BenchHarness;
476+
use deque::bench::{insert_rand_n, insert_seq_n, find_rand_n, find_seq_n};
477477

478478
// Find seq
479479
#[bench]

src/libextra/treemap.rs renamed to src/libcollections/treemap.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1495,9 +1495,9 @@ mod test_treemap {
14951495
#[cfg(test)]
14961496
mod bench {
14971497

1498-
use super::*;
1499-
use test::BenchHarness;
1500-
use container::bench::*;
1498+
use super::TreeMap;
1499+
use extra::test::BenchHarness;
1500+
use deque::bench::{insert_rand_n, insert_seq_n, find_rand_n, find_seq_n};
15011501

15021502
// Find seq
15031503
#[bench]
@@ -1555,7 +1555,7 @@ mod bench {
15551555
#[cfg(test)]
15561556
mod test_set {
15571557

1558-
use super::*;
1558+
use super::{TreeMap, TreeSet};
15591559

15601560
#[test]
15611561
fn test_clear() {

src/libextra/json.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ A basic `ToJson` example using a TreeMap of attribute name / attribute value:
9898
9999
100100
```rust
101+
extern mod collections;
102+
101103
use extra::json;
102104
use extra::json::ToJson;
103-
use extra::treemap::TreeMap;
105+
use collections::TreeMap;
104106
105107
pub struct MyStruct {
106108
attr1: u8,
@@ -185,10 +187,12 @@ Example of `ToJson` trait implementation for TestStruct1.
185187
186188
```rust
187189
extern mod serialize;
190+
extern mod collections;
191+
188192
use extra::json;
189193
use extra::json::ToJson;
190194
use serialize::{Encodable, Decodable};
191-
use extra::treemap::TreeMap;
195+
use collections::TreeMap;
192196
193197
#[deriving(Decodable, Encodable)] // generate Decodable, Encodable impl.
194198
pub struct TestStruct1 {
@@ -236,7 +240,7 @@ use std::to_str;
236240

237241
use serialize::Encodable;
238242
use serialize;
239-
use treemap::TreeMap;
243+
use collections::TreeMap;
240244

241245
macro_rules! if_ok( ($e:expr) => (
242246
match $e { Ok(e) => e, Err(e) => { self.error = Err(e); return } }
@@ -1588,7 +1592,7 @@ mod tests {
15881592

15891593
use std::io;
15901594
use serialize::{Encodable, Decodable};
1591-
use treemap::TreeMap;
1595+
use collections::TreeMap;
15921596

15931597
#[deriving(Eq, Encodable, Decodable)]
15941598
enum Animal {

src/libextra/lib.rs

+2-19
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ extern mod sync;
3838
#[cfg(not(stage0))]
3939
extern mod serialize;
4040

41+
extern mod collections;
42+
4143
#[cfg(stage0)]
4244
pub mod serialize {
4345
#[allow(missing_doc)];
@@ -47,29 +49,10 @@ pub mod serialize {
4749
EncoderHelpers, DecoderHelpers};
4850
}
4951

50-
#[cfg(stage0)]
51-
macro_rules! if_ok (
52-
($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
53-
)
54-
5552
// Utility modules
5653

5754
pub mod c_vec;
5855

59-
// Collections
60-
61-
pub mod container;
62-
pub mod bitv;
63-
pub mod list;
64-
pub mod ringbuf;
65-
pub mod priority_queue;
66-
pub mod smallintmap;
67-
68-
pub mod dlist;
69-
pub mod treemap;
70-
pub mod btree;
71-
pub mod lru_cache;
72-
7356
// And ... other stuff
7457

7558
pub mod url;

src/libextra/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use serialize::Decodable;
2424
use stats::Stats;
2525
use stats;
2626
use time::precise_time_ns;
27-
use treemap::TreeMap;
27+
use collections::TreeMap;
2828

2929
use std::clone::Clone;
3030
use std::io;

src/libextra/workcache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use json;
1414
use json::ToJson;
1515
use serialize::{Encoder, Encodable, Decoder, Decodable};
1616
use sync::{Arc,RWArc};
17-
use treemap::TreeMap;
17+
use collections::TreeMap;
1818
use std::str;
1919
use std::io;
2020
use std::io::{File, MemWriter};

src/librustc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ extern mod syntax;
3838
extern mod serialize;
3939
extern mod sync;
4040
extern mod getopts;
41+
extern mod collections;
4142

4243
use back::link;
4344
use driver::session;

src/librustc/middle/lint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use std::u16;
5656
use std::u32;
5757
use std::u64;
5858
use std::u8;
59-
use extra::smallintmap::SmallIntMap;
59+
use collections::SmallIntMap;
6060
use syntax::ast_map;
6161
use syntax::ast_util::IdVisitingOperation;
6262
use syntax::attr::{AttrMetaMethods, AttributeMethods};

src/librustc/middle/typeck/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub use middle::typeck::infer::resolve::{resolve_ivar, resolve_all};
2020
pub use middle::typeck::infer::resolve::{resolve_nested_tvar};
2121
pub use middle::typeck::infer::resolve::{resolve_rvar};
2222

23-
use extra::smallintmap::SmallIntMap;
23+
use collections::SmallIntMap;
2424
use middle::ty::{TyVid, IntVid, FloatVid, RegionVid, Vid};
2525
use middle::ty;
2626
use middle::ty_fold;

src/librustc/middle/typeck/infer/unify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111

12-
use extra::smallintmap::SmallIntMap;
12+
use collections::SmallIntMap;
1313

1414
use middle::ty::{Vid, expected_found, IntVarValue};
1515
use middle::ty;

src/librustc/middle/typeck/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ use util::ppaux;
7171
use std::cell::RefCell;
7272
use std::hashmap::HashMap;
7373
use std::rc::Rc;
74-
use extra::list::List;
75-
use extra::list;
74+
use collections::List;
75+
use collections::list;
7676
use syntax::codemap::Span;
7777
use syntax::print::pprust::*;
7878
use syntax::{ast, ast_map, abi};

src/librustdoc/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extern mod extra;
2121
extern mod serialize;
2222
extern mod sync;
2323
extern mod getopts;
24+
extern mod collections;
2425

2526
use std::local_data;
2627
use std::io;
@@ -326,7 +327,7 @@ fn json_output(crate: clean::Crate, res: ~[plugins::PluginJson],
326327
// "crate": { parsed crate ... },
327328
// "plugins": { output of plugins ... }
328329
// }
329-
let mut json = ~extra::treemap::TreeMap::new();
330+
let mut json = ~collections::TreeMap::new();
330331
json.insert(~"schema", json::String(SCHEMA_VERSION.to_owned()));
331332
let plugins_json = ~res.move_iter().filter_map(|opt| opt).collect();
332333

src/libsyntax/ast_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use util::small_vector::SmallVector;
2222

2323
use std::logging;
2424
use std::cell::RefCell;
25-
use extra::smallintmap::SmallIntMap;
25+
use collections::SmallIntMap;
2626

2727
#[deriving(Clone, Eq)]
2828
pub enum PathElem {

src/libsyntax/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ This API is completely unstable and subject to change.
3535
extern mod extra;
3636
extern mod serialize;
3737
extern mod term;
38+
extern mod collections;
3839

3940
pub mod util {
4041
pub mod interner;

0 commit comments

Comments
 (0)