Skip to content

Commit a47d52c

Browse files
committed
collections: remove List
It was decided in a meeting that this module wasn't needed, and more thought should be put into a persistent collections library.
1 parent b8601a3 commit a47d52c

File tree

7 files changed

+34
-263
lines changed

7 files changed

+34
-263
lines changed

src/libarena/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
extern crate collections;
2929

30-
use collections::list::{List, Cons, Nil};
31-
3230
use std::cast::{transmute, transmute_mut, transmute_mut_region};
3331
use std::cast;
3432
use std::cell::{Cell, RefCell};
@@ -87,7 +85,7 @@ pub struct Arena {
8785
// access the head.
8886
priv head: Chunk,
8987
priv copy_head: Chunk,
90-
priv chunks: RefCell<@List<Chunk>>,
88+
priv chunks: RefCell<Vec<Chunk>>,
9189
}
9290

9391
impl Arena {
@@ -99,7 +97,7 @@ impl Arena {
9997
Arena {
10098
head: chunk(initial_size, false),
10199
copy_head: chunk(initial_size, true),
102-
chunks: RefCell::new(@Nil),
100+
chunks: RefCell::new(Vec::new()),
103101
}
104102
}
105103
}
@@ -117,7 +115,7 @@ impl Drop for Arena {
117115
fn drop(&mut self) {
118116
unsafe {
119117
destroy_chunk(&self.head);
120-
for chunk in self.chunks.get().iter() {
118+
for chunk in self.chunks.borrow().iter() {
121119
if !chunk.is_copy.get() {
122120
destroy_chunk(chunk);
123121
}
@@ -179,7 +177,7 @@ impl Arena {
179177
fn alloc_copy_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
180178
// Allocate a new chunk.
181179
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
182-
self.chunks.set(@Cons(self.copy_head.clone(), self.chunks.get()));
180+
self.chunks.borrow_mut().push(self.copy_head.clone());
183181
self.copy_head =
184182
chunk(num::next_power_of_two(new_min_chunk_size + 1u), true);
185183

@@ -219,7 +217,7 @@ impl Arena {
219217
-> (*u8, *u8) {
220218
// Allocate a new chunk.
221219
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
222-
self.chunks.set(@Cons(self.head.clone(), self.chunks.get()));
220+
self.chunks.borrow_mut().push(self.head.clone());
223221
self.head =
224222
chunk(num::next_power_of_two(new_min_chunk_size + 1u), false);
225223

src/libcollections/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ pub use deque::Deque;
3333
pub use dlist::DList;
3434
pub use enum_set::EnumSet;
3535
pub use hashmap::{HashMap, HashSet};
36-
pub use list::List;
3736
pub use lru_cache::LruCache;
3837
pub use priority_queue::PriorityQueue;
3938
pub use ringbuf::RingBuf;
@@ -47,7 +46,6 @@ pub mod deque;
4746
pub mod dlist;
4847
pub mod enum_set;
4948
pub mod hashmap;
50-
pub mod list;
5149
pub mod lru_cache;
5250
pub mod priority_queue;
5351
pub mod ringbuf;

src/libcollections/list.rs

Lines changed: 0 additions & 237 deletions
This file was deleted.

src/librustc/middle/typeck/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ use util::nodemap::{DefIdMap, FnvHashMap};
7272

7373
use std::cell::RefCell;
7474
use std::rc::Rc;
75-
use collections::List;
7675
use syntax::codemap::Span;
7776
use syntax::print::pprust::*;
7877
use syntax::{ast, ast_map, abi};
@@ -327,7 +326,7 @@ pub fn require_same_types(tcx: &ty::ctxt,
327326

328327
// a list of mapping from in-scope-region-names ("isr") to the
329328
// corresponding ty::Region
330-
pub type isr_alist = @List<(ty::BoundRegion, ty::Region)>;
329+
pub type isr_alist = @Vec<(ty::BoundRegion, ty::Region)>;
331330

332331
trait get_region<'a, T:'static> {
333332
fn get(&'a self, br: ty::BoundRegion) -> ty::Region;

src/test/bench/task-perf-alloc-unwind.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@
1313
extern crate collections;
1414
extern crate time;
1515

16-
use collections::list::{List, Cons, Nil};
1716
use time::precise_time_s;
1817
use std::os;
1918
use std::task;
2019
use std::vec;
2120

21+
#[deriving(Clone)]
22+
enum List<T> {
23+
Nil, Cons(T, @List<T>)
24+
}
25+
2226
enum UniqueList {
2327
ULNil, ULCons(~UniqueList)
2428
}

src/test/run-pass/log-knows-the-names-of-variants-in-std.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
// option. This file may not be copied, modified, or distributed
1111
// except according to those terms.
1212

13-
extern crate collections;
14-
use collections::list::List;
15-
1613
#[deriving(Clone)]
1714
enum foo {
1815
a(uint),
@@ -24,9 +21,21 @@ fn check_log<T>(exp: ~str, v: T) {
2421
}
2522

2623
pub fn main() {
27-
let x = List::from_vec([a(22u), b(~"hi")]);
28-
let exp = ~"Cons(a(22u), @Cons(b(~\"hi\"), @Nil))";
24+
let mut x = Some(a(22u));
25+
let exp = ~"Some(a(22u))";
26+
let act = format!("{:?}", x);
27+
assert_eq!(act, exp);
28+
check_log(exp, x);
29+
30+
x = Some(b(~"hi"));
31+
let exp = ~"Some(b(~\"hi\"))";
32+
let act = format!("{:?}", x);
33+
assert_eq!(act, exp);
34+
check_log(exp, x);
35+
36+
x = None;
37+
let exp = ~"None";
2938
let act = format!("{:?}", x);
30-
assert!(act == exp);
39+
assert_eq!(act, exp);
3140
check_log(exp, x);
3241
}

0 commit comments

Comments
 (0)