Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup #7420

Closed
wants to merge 22 commits into from
Closed

Rollup #7420

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[submodule "src/llvm"]
path = src/llvm
url = https://github.com/brson/llvm.git
branch = master
[submodule "src/libuv"]
path = src/libuv
url = https://github.com/brson/libuv.git
branch = master
25 changes: 17 additions & 8 deletions RELEASES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Version 0.7 (July 2013)
* ??? changes, numerous bugfixes

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

Version 0.6 (April 2013)
------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/etc/combine-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def scrub(b):
for t in stage2_tests:
p = os.path.join("test", "run-pass", t)
p = p.replace("\\", "\\\\")
d.write(" out.write_str(~\"run-pass [stage2]: %s\\n\");\n" % p)
d.write(" out.write_str(\"run-pass [stage2]: %s\\n\");\n" % p)
d.write(" t_%d::main();\n" % i)
i += 1
d.write("}\n")
112 changes: 109 additions & 3 deletions src/libextra/deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
// except according to those terms.

//! A double-ended queue implemented as a circular buffer

use core::prelude::*;

use core::uint;
use core::util::replace;
use core::vec;
use core::cast::transmute;

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

Expand Down Expand Up @@ -153,7 +153,86 @@ impl<T> Deque<T> {
pub fn reserve_at_least(&mut self, n: uint) {
vec::reserve_at_least(&mut self.elts, n);
}

/// Front-to-back iterator.
pub fn iter<'a>(&'a self) -> DequeIterator<'a, T> {
DequeIterator { idx: self.lo, nelts: self.nelts, used: 0, vec: self.elts }
}

/// Front-to-back iterator which returns mutable values.
pub fn mut_iter<'a>(&'a mut self) -> DequeMutIterator<'a, T> {
DequeMutIterator { idx: self.lo, nelts: self.nelts, used: 0, vec: self.elts }
}

/// Back-to-front iterator.
pub fn rev_iter<'a>(&'a self) -> DequeRevIterator<'a, T> {
DequeRevIterator { idx: self.hi - 1u, nelts: self.nelts, used: 0, vec: self.elts }
}

/// Back-to-front iterator which returns mutable values.
pub fn mut_rev_iter<'a>(&'a mut self) -> DequeMutRevIterator<'a, T> {
DequeMutRevIterator { idx: self.hi - 1u, nelts: self.nelts, used: 0, vec: self.elts }
}
}

macro_rules! iterator {
(impl $name:ident -> $elem:ty, $step:expr) => {
impl<'self, T> Iterator<$elem> for $name<'self, T> {
#[inline]
fn next(&mut self) -> Option<$elem> {
if self.used >= self.nelts {
return None;
}
let ret = unsafe {
match self.vec[self.idx % self.vec.len()] {
Some(ref e) => Some(transmute(e)),
None => None
}
};
self.idx += $step;
self.used += 1;
ret
}
}
}
}

/// Deque iterator
pub struct DequeIterator<'self, T> {
priv idx: uint,
priv nelts: uint,
priv used: uint,
priv vec: &'self [Option<T>]
}
iterator!{impl DequeIterator -> &'self T, 1}

/// Deque reverse iterator
pub struct DequeRevIterator<'self, T> {
priv idx: uint,
priv nelts: uint,
priv used: uint,
priv vec: &'self [Option<T>]
}
iterator!{impl DequeRevIterator -> &'self T, -1}

/// Deque mutable iterator
pub struct DequeMutIterator<'self, T> {
priv idx: uint,
priv nelts: uint,
priv used: uint,
priv vec: &'self mut [Option<T>]

}
iterator!{impl DequeMutIterator -> &'self mut T, 1}

/// Deque mutable reverse iterator
pub struct DequeMutRevIterator<'self, T> {
priv idx: uint,
priv nelts: uint,
priv used: uint,
priv vec: &'self mut [Option<T>]
}
iterator!{impl DequeMutRevIterator -> &'self mut T, -1}

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

#[test]
fn test_simple() {
Expand Down Expand Up @@ -318,8 +398,7 @@ mod tests {

#[test]
fn test_param_taggy() {
test_parameterized::<Taggy>(One(1), Two(1, 2), Three(1, 2, 3),
Two(17, 42));
test_parameterized::<Taggy>(One(1), Two(1, 2), Three(1, 2, 3), Two(17, 42));
}

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

#[test]
fn test_iter() {
let mut d = Deque::new();
for core::int::range(0,5) |i| {
d.add_back(i);
}
assert_eq!(d.iter().collect::<~[&int]>(), ~[&0,&1,&2,&3,&4]);

for core::int::range(6,9) |i| {
d.add_front(i);
}
assert_eq!(d.iter().collect::<~[&int]>(), ~[&8,&7,&6,&0,&1,&2,&3,&4]);
}

#[test]
fn test_rev_iter() {
let mut d = Deque::new();
for core::int::range(0,5) |i| {
d.add_back(i);
}
assert_eq!(d.rev_iter().collect::<~[&int]>(), ~[&4,&3,&2,&1,&0]);

for core::int::range(6,9) |i| {
d.add_front(i);
}
assert_eq!(d.rev_iter().collect::<~[&int]>(), ~[&4,&3,&2,&1,&0,&6,&7,&8]);
}
}
31 changes: 27 additions & 4 deletions src/libextra/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ impl<T:Ord> Mutable for PriorityQueue<T> {
}

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

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

/// PriorityQueue iterator
pub struct PriorityQueueIterator <'self, T> {
priv iter: vec::VecIterator<'self, T>,
}

impl<'self, T> Iterator<&'self T> for PriorityQueueIterator<'self, T> {
#[inline]
fn next(&mut self) -> Option<(&'self T)> { self.iter.next() }
}

#[cfg(test)]
mod tests {
use sort::merge_sort;
use priority_queue::PriorityQueue;

#[test]
fn test_iterator() {
let data = ~[5, 9, 3];
let iterout = ~[9, 5, 3];
let pq = PriorityQueue::from_vec(data);
let mut i = 0;
for pq.iter().advance |el| {
assert_eq!(*el, iterout[i]);
i += 1;
}
}

#[test]
fn test_top_and_pop() {
let data = ~[2u, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1];
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ impl<
fn encode(&self, e: &mut E) {
do e.emit_map(self.len()) |e| {
let mut i = 0;
for self.each |key, val| {
for self.iter().advance |(key, val)| {
e.emit_map_elt_key(i, |e| key.encode(e));
e.emit_map_elt_val(i, |e| val.encode(e));
i += 1;
Expand Down Expand Up @@ -866,7 +866,7 @@ impl<
fn encode(&self, s: &mut S) {
do s.emit_seq(self.len()) |s| {
let mut i = 0;
for self.each |e| {
for self.iter().advance |e| {
s.emit_seq_elt(i, |s| e.encode(s));
i += 1;
}
Expand Down
Loading