Skip to content

Commit f1e09d6

Browse files
committed
auto merge of #7420 : mozilla/rust/rollup, r=thestinger
2 parents eda5e40 + ab428b6 commit f1e09d6

23 files changed

+474
-325
lines changed

Diff for: .gitmodules

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[submodule "src/llvm"]
22
path = src/llvm
33
url = https://github.com/brson/llvm.git
4+
branch = master
45
[submodule "src/libuv"]
56
path = src/libuv
67
url = https://github.com/brson/libuv.git
8+
branch = master

Diff for: RELEASES.txt

+17-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Version 0.7 (July 2013)
44
* ??? changes, numerous bugfixes
55

66
* Syntax changes
7+
* `impl`s no longer accept a visibility qualifier. Put them on methods
8+
instead.
79
* `use mod` is no longer valid.
810
* `fail!` and `assert!` accept `~str`, `&'static str` or `fmt!`-style
911
argument list.
@@ -25,6 +27,10 @@ Version 0.7 (July 2013)
2527
no padding between fields.
2628
* The `for` loop protocol now requires `for`-iterators to return `bool`
2729
so they compose better.
30+
* Trait default methods work more often.
31+
* Type parameters bound by `Copy` must now be copied explicitly with
32+
the `copy` keyword.
33+
* It is now illegal to move out of a dereferenced unsafe pointer.
2834
* `Option<~T>` is now represented as a nullable pointer.
2935
* `@mut` does dynamic borrow checks correctly.
3036
* Macros TODO
@@ -43,26 +49,30 @@ Version 0.7 (July 2013)
4349
* Libraries
4450
* The `core` crate was renamed to `std`.
4551
* The `std` crate was renamed to `extra`.
46-
* `std::mut` removed.
47-
* std: The prelude no longer reexports any modules, only types and traits.
48-
* std: Prelude additions: `print`, `println`, `FromStr`, `ApproxEq`, `Equiv`,
49-
`Iterator`, `IteratorUtil`, many numeric traits, many tuple traits.
5052
* std: `iterator` module for external iterator objects.
53+
* Many old-style (internal, higher-order function) iterators replaced by
54+
implementations of `Iterator`.
5155
* std: Many old internal vector and string iterators,
5256
incl. `any`, `all`. removed.
53-
* std: new numeric traits: `Fractional`, `Real`, `RealExt`, `Integer`, `Ratio`,
57+
* std: The `finalize` method of `Drop` renamed to `drop`.
58+
* std: The prelude no longer reexports any modules, only types and traits.
59+
* std: Prelude additions: `print`, `println`, `FromStr`, `ApproxEq`, `Equiv`,
60+
`Iterator`, `IteratorUtil`, many numeric traits, many tuple traits.
61+
* std: New numeric traits: `Fractional`, `Real`, `RealExt`, `Integer`, `Ratio`,
5462
`Algebraic`, `Trigonometric`, `Exponential`, `Primitive`.
5563
* std: Tuple traits and accessors defined for up to 12-tuples, e.g.
5664
`(0, 1, 2).n2()` or `(0, 1, 2).n2_ref()`.
57-
* std: many types implement `Clone`.
65+
* std: Many types implement `Clone`.
5866
* std: `path` type renamed to `Path`.
67+
* std: `mut` module and `Mut` type removed.
5968
* std: Many standalone functions removed in favor of methods and iterators
6069
in `vec`, `str`. In the future methods will also work as functions.
61-
* std: `reinterpret_cast` removed. Used `transmute`.
70+
* std: `reinterpret_cast` removed. Use `transmute`.
6271
* std: ascii string handling in `std::ascii`.
6372
* std: `Rand` is implemented for ~/@.
6473
* std: `run` module for spawning processes overhauled.
6574
* std: Various atomic types added to `unstable::atomic`.
75+
* std: Various types implement `Zero`.
6676
* std: `LinearMap` and `LinearSet` renamed to `HashMap` and `HashSet`.
6777
* std: Borrowed pointer functions moved from `ptr` to `borrow`.
6878
* std: Added `os::mkdir_recursive`.
@@ -96,7 +106,6 @@ Version 0.7 (July 2013)
96106
* More and improved library documentation.
97107
* Various improvements on ARM and Android.
98108
* Various improvements to MIPS backend.
99-
* jemalloc is the Rust allocator.
100109

101110
Version 0.6 (April 2013)
102111
------------------------

Diff for: src/etc/combine-tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def scrub(b):
6060
for t in stage2_tests:
6161
p = os.path.join("test", "run-pass", t)
6262
p = p.replace("\\", "\\\\")
63-
d.write(" out.write_str(~\"run-pass [stage2]: %s\\n\");\n" % p)
63+
d.write(" out.write_str(\"run-pass [stage2]: %s\\n\");\n" % p)
6464
d.write(" t_%d::main();\n" % i)
6565
i += 1
6666
d.write("}\n")

Diff for: src/libextra/deque.rs

+109-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
// except according to those terms.
1010

1111
//! A double-ended queue implemented as a circular buffer
12-
1312
use core::prelude::*;
1413

1514
use core::uint;
1615
use core::util::replace;
1716
use core::vec;
17+
use core::cast::transmute;
1818

1919
static initial_capacity: uint = 32u; // 2^5
2020

@@ -153,7 +153,86 @@ impl<T> Deque<T> {
153153
pub fn reserve_at_least(&mut self, n: uint) {
154154
vec::reserve_at_least(&mut self.elts, n);
155155
}
156+
157+
/// Front-to-back iterator.
158+
pub fn iter<'a>(&'a self) -> DequeIterator<'a, T> {
159+
DequeIterator { idx: self.lo, nelts: self.nelts, used: 0, vec: self.elts }
160+
}
161+
162+
/// Front-to-back iterator which returns mutable values.
163+
pub fn mut_iter<'a>(&'a mut self) -> DequeMutIterator<'a, T> {
164+
DequeMutIterator { idx: self.lo, nelts: self.nelts, used: 0, vec: self.elts }
165+
}
166+
167+
/// Back-to-front iterator.
168+
pub fn rev_iter<'a>(&'a self) -> DequeRevIterator<'a, T> {
169+
DequeRevIterator { idx: self.hi - 1u, nelts: self.nelts, used: 0, vec: self.elts }
170+
}
171+
172+
/// Back-to-front iterator which returns mutable values.
173+
pub fn mut_rev_iter<'a>(&'a mut self) -> DequeMutRevIterator<'a, T> {
174+
DequeMutRevIterator { idx: self.hi - 1u, nelts: self.nelts, used: 0, vec: self.elts }
175+
}
176+
}
177+
178+
macro_rules! iterator {
179+
(impl $name:ident -> $elem:ty, $step:expr) => {
180+
impl<'self, T> Iterator<$elem> for $name<'self, T> {
181+
#[inline]
182+
fn next(&mut self) -> Option<$elem> {
183+
if self.used >= self.nelts {
184+
return None;
185+
}
186+
let ret = unsafe {
187+
match self.vec[self.idx % self.vec.len()] {
188+
Some(ref e) => Some(transmute(e)),
189+
None => None
190+
}
191+
};
192+
self.idx += $step;
193+
self.used += 1;
194+
ret
195+
}
196+
}
197+
}
198+
}
199+
200+
/// Deque iterator
201+
pub struct DequeIterator<'self, T> {
202+
priv idx: uint,
203+
priv nelts: uint,
204+
priv used: uint,
205+
priv vec: &'self [Option<T>]
156206
}
207+
iterator!{impl DequeIterator -> &'self T, 1}
208+
209+
/// Deque reverse iterator
210+
pub struct DequeRevIterator<'self, T> {
211+
priv idx: uint,
212+
priv nelts: uint,
213+
priv used: uint,
214+
priv vec: &'self [Option<T>]
215+
}
216+
iterator!{impl DequeRevIterator -> &'self T, -1}
217+
218+
/// Deque mutable iterator
219+
pub struct DequeMutIterator<'self, T> {
220+
priv idx: uint,
221+
priv nelts: uint,
222+
priv used: uint,
223+
priv vec: &'self mut [Option<T>]
224+
225+
}
226+
iterator!{impl DequeMutIterator -> &'self mut T, 1}
227+
228+
/// Deque mutable reverse iterator
229+
pub struct DequeMutRevIterator<'self, T> {
230+
priv idx: uint,
231+
priv nelts: uint,
232+
priv used: uint,
233+
priv vec: &'self mut [Option<T>]
234+
}
235+
iterator!{impl DequeMutRevIterator -> &'self mut T, -1}
157236

158237
/// Grow is only called on full elts, so nelts is also len(elts), unlike
159238
/// elsewhere.
@@ -178,6 +257,7 @@ mod tests {
178257
use core::cmp::Eq;
179258
use core::kinds::Copy;
180259
use core::vec::capacity;
260+
use core;
181261

182262
#[test]
183263
fn test_simple() {
@@ -318,8 +398,7 @@ mod tests {
318398

319399
#[test]
320400
fn test_param_taggy() {
321-
test_parameterized::<Taggy>(One(1), Two(1, 2), Three(1, 2, 3),
322-
Two(17, 42));
401+
test_parameterized::<Taggy>(One(1), Two(1, 2), Three(1, 2, 3), Two(17, 42));
323402
}
324403

325404
#[test]
@@ -382,4 +461,31 @@ mod tests {
382461
assert_eq!(capacity(&mut d.elts), 64);
383462
}
384463

464+
#[test]
465+
fn test_iter() {
466+
let mut d = Deque::new();
467+
for core::int::range(0,5) |i| {
468+
d.add_back(i);
469+
}
470+
assert_eq!(d.iter().collect::<~[&int]>(), ~[&0,&1,&2,&3,&4]);
471+
472+
for core::int::range(6,9) |i| {
473+
d.add_front(i);
474+
}
475+
assert_eq!(d.iter().collect::<~[&int]>(), ~[&8,&7,&6,&0,&1,&2,&3,&4]);
476+
}
477+
478+
#[test]
479+
fn test_rev_iter() {
480+
let mut d = Deque::new();
481+
for core::int::range(0,5) |i| {
482+
d.add_back(i);
483+
}
484+
assert_eq!(d.rev_iter().collect::<~[&int]>(), ~[&4,&3,&2,&1,&0]);
485+
486+
for core::int::range(6,9) |i| {
487+
d.add_front(i);
488+
}
489+
assert_eq!(d.rev_iter().collect::<~[&int]>(), ~[&4,&3,&2,&1,&0,&6,&7,&8]);
490+
}
385491
}

Diff for: src/libextra/priority_queue.rs

+27-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ impl<T:Ord> Mutable for PriorityQueue<T> {
3737
}
3838

3939
impl<T:Ord> PriorityQueue<T> {
40-
/// Visit all values in the underlying vector.
41-
///
42-
/// The values are **not** visited in order.
43-
pub fn each(&self, f: &fn(&T) -> bool) -> bool { self.data.iter().advance(f) }
40+
/// An iterator visiting all values in underlying vector, in
41+
/// arbitrary order.
42+
pub fn iter<'a>(&'a self) -> PriorityQueueIterator<'a, T> {
43+
PriorityQueueIterator { iter: self.data.iter() }
44+
}
4445

4546
/// Returns the greatest item in the queue - fails if empty
4647
pub fn top<'a>(&'a self) -> &'a T { &self.data[0] }
@@ -178,11 +179,33 @@ impl<T:Ord> PriorityQueue<T> {
178179
}
179180
}
180181

182+
/// PriorityQueue iterator
183+
pub struct PriorityQueueIterator <'self, T> {
184+
priv iter: vec::VecIterator<'self, T>,
185+
}
186+
187+
impl<'self, T> Iterator<&'self T> for PriorityQueueIterator<'self, T> {
188+
#[inline]
189+
fn next(&mut self) -> Option<(&'self T)> { self.iter.next() }
190+
}
191+
181192
#[cfg(test)]
182193
mod tests {
183194
use sort::merge_sort;
184195
use priority_queue::PriorityQueue;
185196

197+
#[test]
198+
fn test_iterator() {
199+
let data = ~[5, 9, 3];
200+
let iterout = ~[9, 5, 3];
201+
let pq = PriorityQueue::from_vec(data);
202+
let mut i = 0;
203+
for pq.iter().advance |el| {
204+
assert_eq!(*el, iterout[i]);
205+
i += 1;
206+
}
207+
}
208+
186209
#[test]
187210
fn test_top_and_pop() {
188211
let data = ~[2u, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1];

Diff for: src/libextra/serialize.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ impl<
832832
fn encode(&self, e: &mut E) {
833833
do e.emit_map(self.len()) |e| {
834834
let mut i = 0;
835-
for self.each |key, val| {
835+
for self.iter().advance |(key, val)| {
836836
e.emit_map_elt_key(i, |e| key.encode(e));
837837
e.emit_map_elt_val(i, |e| val.encode(e));
838838
i += 1;
@@ -866,7 +866,7 @@ impl<
866866
fn encode(&self, s: &mut S) {
867867
do s.emit_seq(self.len()) |s| {
868868
let mut i = 0;
869-
for self.each |e| {
869+
for self.iter().advance |e| {
870870
s.emit_seq_elt(i, |s| e.encode(s));
871871
i += 1;
872872
}

0 commit comments

Comments
 (0)