Skip to content

Commit f203fc7

Browse files
committed
auto merge of #12348 : brunoabinader/rust/libcollections-list-refactory, r=alexcrichton
This PR includes: - Create an iterator for ```List<T>``` called ```Items<T>```; - Move all list operations inside ```List<T>``` impl; - Removed functions that are already provided by ```Iterator``` trait; - Refactor on ```len()``` and ```is_empty``` using ```Container``` trait; - Bunch of minor fixes; A replacement for using @ is intended, but still in discussion. Closes #12344.
2 parents 700fd35 + 4da6d04 commit f203fc7

File tree

7 files changed

+177
-217
lines changed

7 files changed

+177
-217
lines changed

src/doc/rust.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3256,10 +3256,10 @@ An example of a *recursive* type and its use:
32563256
~~~~
32573257
enum List<T> {
32583258
Nil,
3259-
Cons(T, @List<T>)
3259+
Cons(T, ~List<T>)
32603260
}
32613261
3262-
let a: List<int> = Cons(7, @Cons(13, @Nil));
3262+
let a: List<int> = Cons(7, ~Cons(13, ~Nil));
32633263
~~~~
32643264

32653265
### Pointer types

src/libarena/lib.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
extern crate collections;
2626

2727
use collections::list::{List, Cons, Nil};
28-
use collections::list;
2928

3029
use std::cast::{transmute, transmute_mut, transmute_mut_region};
3130
use std::cast;
@@ -44,7 +43,7 @@ use std::vec;
4443
// The way arena uses arrays is really deeply awful. The arrays are
4544
// allocated, and have capacities reserved, but the fill for the array
4645
// will always stay at 0.
47-
#[deriving(Clone)]
46+
#[deriving(Clone, Eq)]
4847
struct Chunk {
4948
data: Rc<RefCell<~[u8]>>,
5049
fill: Cell<uint>,
@@ -119,13 +118,11 @@ impl Drop for Arena {
119118
fn drop(&mut self) {
120119
unsafe {
121120
destroy_chunk(&self.head);
122-
123-
list::each(self.chunks.get(), |chunk| {
121+
for chunk in self.chunks.get().iter() {
124122
if !chunk.is_pod.get() {
125123
destroy_chunk(chunk);
126124
}
127-
true
128-
});
125+
}
129126
}
130127
}
131128
}

0 commit comments

Comments
 (0)