Skip to content

Commit

Permalink
collections: remove List
Browse files Browse the repository at this point in the history
It was decided in a meeting that this module wasn't needed,
and more thought should be put into a persistent collections
library.
  • Loading branch information
erickt committed Mar 28, 2014
1 parent b8601a3 commit a47d52c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 263 deletions.
12 changes: 5 additions & 7 deletions src/libarena/lib.rs
Expand Up @@ -27,8 +27,6 @@

extern crate collections;

use collections::list::{List, Cons, Nil};

use std::cast::{transmute, transmute_mut, transmute_mut_region};
use std::cast;
use std::cell::{Cell, RefCell};
Expand Down Expand Up @@ -87,7 +85,7 @@ pub struct Arena {
// access the head.
priv head: Chunk,
priv copy_head: Chunk,
priv chunks: RefCell<@List<Chunk>>,
priv chunks: RefCell<Vec<Chunk>>,
}

impl Arena {
Expand All @@ -99,7 +97,7 @@ impl Arena {
Arena {
head: chunk(initial_size, false),
copy_head: chunk(initial_size, true),
chunks: RefCell::new(@Nil),
chunks: RefCell::new(Vec::new()),
}
}
}
Expand All @@ -117,7 +115,7 @@ impl Drop for Arena {
fn drop(&mut self) {
unsafe {
destroy_chunk(&self.head);
for chunk in self.chunks.get().iter() {
for chunk in self.chunks.borrow().iter() {
if !chunk.is_copy.get() {
destroy_chunk(chunk);
}
Expand Down Expand Up @@ -179,7 +177,7 @@ impl Arena {
fn alloc_copy_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
// Allocate a new chunk.
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
self.chunks.set(@Cons(self.copy_head.clone(), self.chunks.get()));
self.chunks.borrow_mut().push(self.copy_head.clone());
self.copy_head =
chunk(num::next_power_of_two(new_min_chunk_size + 1u), true);

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

Expand Down
2 changes: 0 additions & 2 deletions src/libcollections/lib.rs
Expand Up @@ -33,7 +33,6 @@ pub use deque::Deque;
pub use dlist::DList;
pub use enum_set::EnumSet;
pub use hashmap::{HashMap, HashSet};
pub use list::List;
pub use lru_cache::LruCache;
pub use priority_queue::PriorityQueue;
pub use ringbuf::RingBuf;
Expand All @@ -47,7 +46,6 @@ pub mod deque;
pub mod dlist;
pub mod enum_set;
pub mod hashmap;
pub mod list;
pub mod lru_cache;
pub mod priority_queue;
pub mod ringbuf;
Expand Down
237 changes: 0 additions & 237 deletions src/libcollections/list.rs

This file was deleted.

3 changes: 1 addition & 2 deletions src/librustc/middle/typeck/mod.rs
Expand Up @@ -72,7 +72,6 @@ use util::nodemap::{DefIdMap, FnvHashMap};

use std::cell::RefCell;
use std::rc::Rc;
use collections::List;
use syntax::codemap::Span;
use syntax::print::pprust::*;
use syntax::{ast, ast_map, abi};
Expand Down Expand Up @@ -327,7 +326,7 @@ pub fn require_same_types(tcx: &ty::ctxt,

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

trait get_region<'a, T:'static> {
fn get(&'a self, br: ty::BoundRegion) -> ty::Region;
Expand Down
6 changes: 5 additions & 1 deletion src/test/bench/task-perf-alloc-unwind.rs
Expand Up @@ -13,12 +13,16 @@
extern crate collections;
extern crate time;

use collections::list::{List, Cons, Nil};
use time::precise_time_s;
use std::os;
use std::task;
use std::vec;

#[deriving(Clone)]
enum List<T> {
Nil, Cons(T, @List<T>)
}

enum UniqueList {
ULNil, ULCons(~UniqueList)
}
Expand Down
21 changes: 15 additions & 6 deletions src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
Expand Up @@ -10,9 +10,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

extern crate collections;
use collections::list::List;

#[deriving(Clone)]
enum foo {
a(uint),
Expand All @@ -24,9 +21,21 @@ fn check_log<T>(exp: ~str, v: T) {
}

pub fn main() {
let x = List::from_vec([a(22u), b(~"hi")]);
let exp = ~"Cons(a(22u), @Cons(b(~\"hi\"), @Nil))";
let mut x = Some(a(22u));
let exp = ~"Some(a(22u))";
let act = format!("{:?}", x);
assert_eq!(act, exp);
check_log(exp, x);

x = Some(b(~"hi"));
let exp = ~"Some(b(~\"hi\"))";
let act = format!("{:?}", x);
assert_eq!(act, exp);
check_log(exp, x);

x = None;
let exp = ~"None";
let act = format!("{:?}", x);
assert!(act == exp);
assert_eq!(act, exp);
check_log(exp, x);
}

0 comments on commit a47d52c

Please sign in to comment.