make way for a new iter module

This commit is contained in:
Daniel Micay 2013-04-24 20:35:49 -04:00
parent 9f03d45c56
commit 46f91a0fa9
42 changed files with 648 additions and 540 deletions

View file

@ -30,7 +30,7 @@ fn main() {
}
fn run(repeat: int, depth: int) {
for iter::repeat(repeat as uint) {
for old_iter::repeat(repeat as uint) {
debug!("starting %.4f", precise_time_s());
do task::try {
recurse_or_fail(depth, None)

View file

@ -12,6 +12,8 @@
// Testing that runtime failure doesn't cause callbacks to abort abnormally.
// Instead the failure will be delivered after the callbacks return.
use core::old_iter;
mod rustrt {
pub extern {
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
@ -35,7 +37,7 @@ fn count(n: uint) -> uint {
}
fn main() {
for iter::repeat(10u) {
for old_iter::repeat(10u) {
do task::spawn {
let result = count(5u);
debug!("result = %?", result);

View file

@ -21,5 +21,5 @@ fn bitv_test() -> bool {
}
pub fn main() {
do iter::repeat(10000) || {bitv_test()};
do old_iter::repeat(10000) || {bitv_test()};
}

View file

@ -11,7 +11,7 @@
// xfail-fast
use core::container::{Container, Mutable, Map};
use core::iter::BaseIter;
use core::old_iter::BaseIter;
enum cat_type { tuxedo, tabby, tortoiseshell }

View file

@ -14,7 +14,7 @@ extern mod std;
use std::oldmap::{map, hashmap, int_hash};
class keys<K:Copy,V:Copy,M:Copy + map<K,V>>
: iter::base_iter<K> {
: old_iter::base_iter<K> {
let map: M;
@ -24,12 +24,12 @@ class keys<K:Copy,V:Copy,M:Copy + map<K,V>>
fn each(blk: &fn(K) -> bool) { self.map.each(|k, _v| blk(k) ) }
fn size_hint() -> Option<uint> { Some(self.map.size()) }
fn eachi(blk: &fn(uint, K) -> bool) { iter::eachi(self, blk) }
fn eachi(blk: &fn(uint, K) -> bool) { old_iter::eachi(self, blk) }
}
pub fn main() {
let m = int_hash();
m.insert(1, 2);
m.insert(3, 4);
assert!(iter::to_vec(keys(m)) == ~[1, 3]);
assert!(old_iter::to_vec(keys(m)) == ~[1, 3]);
}

View file

@ -21,7 +21,7 @@ struct A { a: int }
pub fn main() {
for iter::eachi(&(Some(A {a: 0}))) |i, a| {
for old_iter::eachi(&(Some(A {a: 0}))) |i, a| {
debug!("%u %d", i, a.a);
}

View file

@ -34,7 +34,7 @@ fn count(n: uint) -> uint {
}
pub fn main() {
for iter::repeat(100u) {
for old_iter::repeat(100u) {
do task::spawn {
assert!(count(5u) == 16u);
};

View file

@ -31,7 +31,7 @@ fn count(n: uint) -> uint {
}
pub fn main() {
for iter::repeat(10u) {
for old_iter::repeat(10u) {
do task::spawn {
let result = count(5u);
debug!("result = %?", result);

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::iter::BaseIter;
use core::old_iter::BaseIter;
trait FlatMapToVec<A> {
fn flat_map_to_vec<B, IB:BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B];
@ -16,7 +16,7 @@ trait FlatMapToVec<A> {
impl<A:Copy> FlatMapToVec<A> for ~[A] {
fn flat_map_to_vec<B, IB:BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B] {
iter::flat_map_to_vec(self, op)
old_iter::flat_map_to_vec(self, op)
}
}

View file

@ -15,7 +15,7 @@ pub fn main() {
assert!([2u, 4u].all(is_even));
assert!([].all(is_even));
assert!(!iter::all(&Some(1u), is_even));
assert!(iter::all(&Some(2u), is_even));
assert!(iter::all(&None::<uint>, is_even));
assert!(!old_iter::all(&Some(1u), is_even));
assert!(old_iter::all(&Some(2u), is_even));
assert!(old_iter::all(&None::<uint>, is_even));
}

View file

@ -15,7 +15,7 @@ pub fn main() {
assert!([1u, 2u].any(is_even));
assert!(![].any(is_even));
assert!(!iter::any(&Some(1u), is_even));
assert!(iter::any(&Some(2u), is_even));
assert!(!iter::any(&None::<uint>, is_even));
assert!(!old_iter::any(&Some(1u), is_even));
assert!(old_iter::any(&Some(2u), is_even));
assert!(!old_iter::any(&None::<uint>, is_even));
}

View file

@ -14,7 +14,7 @@ pub fn main() {
assert!([22u, 1u, 3u].contains(&22u) == true);
assert!([1u, 22u, 3u].contains(&22u) == true);
assert!([1u, 3u, 22u].contains(&22u) == true);
assert!(iter::contains(&None::<uint>, &22u) == false);
assert!(iter::contains(&Some(1u), &22u) == false);
assert!(iter::contains(&Some(22u), &22u) == true);
assert!(old_iter::contains(&None::<uint>, &22u) == false);
assert!(old_iter::contains(&Some(1u), &22u) == false);
assert!(old_iter::contains(&Some(22u), &22u) == true);
}

View file

@ -13,7 +13,7 @@ pub fn main() {
assert!([1u, 3u].count(&22u) == 0u);
assert!([22u, 1u, 3u].count(&22u) == 1u);
assert!([22u, 1u, 22u].count(&22u) == 2u);
assert!(iter::count(&None::<uint>, &22u) == 0u);
assert!(iter::count(&Some(1u), &22u) == 0u);
assert!(iter::count(&Some(22u), &22u) == 1u);
assert!(old_iter::count(&None::<uint>, &22u) == 0u);
assert!(old_iter::count(&Some(1u), &22u) == 0u);
assert!(old_iter::count(&Some(22u), &22u) == 1u);
}

View file

@ -16,10 +16,10 @@ pub fn main() {
}
assert!(c == 5u);
for iter::eachi(&None::<uint>) |i, v| { fail!(); }
for old_iter::eachi(&None::<uint>) |i, v| { fail!(); }
let mut c = 0u;
for iter::eachi(&Some(1u)) |i, v| {
for old_iter::eachi(&Some(1u)) |i, v| {
assert!((i + 1u) == *v);
c += 1u;
}

View file

@ -13,7 +13,7 @@ fn is_even(x: &uint) -> bool { (*x % 2) == 0 }
pub fn main() {
assert!([1, 3].filter_to_vec(is_even) == ~[]);
assert!([1, 2, 3].filter_to_vec(is_even) == ~[2]);
assert!(iter::filter_to_vec(&None::<uint>, is_even) == ~[]);
assert!(iter::filter_to_vec(&Some(1u), is_even) == ~[]);
assert!(iter::filter_to_vec(&Some(2u), is_even) == ~[2]);
assert!(old_iter::filter_to_vec(&None::<uint>, is_even) == ~[]);
assert!(old_iter::filter_to_vec(&Some(1u), is_even) == ~[]);
assert!(old_iter::filter_to_vec(&Some(2u), is_even) == ~[2]);
}

View file

@ -17,13 +17,13 @@ fn incd_if_even(x: &uint) -> Option<uint> {
pub fn main() {
assert!((~[1u, 3u]).flat_map_to_vec(repeat) == ~[1u, 1u, 3u, 3u]);
assert!((~[]).flat_map_to_vec(repeat) == ~[]);
assert!(iter::flat_map_to_vec(&None::<uint>, repeat) == ~[]);
assert!(iter::flat_map_to_vec(&Some(1u), repeat) == ~[1u, 1u]);
assert!(iter::flat_map_to_vec(&Some(2u), repeat) == ~[2u, 2u]);
assert!(old_iter::flat_map_to_vec(&None::<uint>, repeat) == ~[]);
assert!(old_iter::flat_map_to_vec(&Some(1u), repeat) == ~[1u, 1u]);
assert!(old_iter::flat_map_to_vec(&Some(2u), repeat) == ~[2u, 2u]);
assert!((~[1u, 2u, 5u]).flat_map_to_vec(incd_if_even) == ~[3u]);
assert!((~[]).flat_map_to_vec(incd_if_even) == ~[]);
assert!(iter::flat_map_to_vec(&None::<uint>, incd_if_even) == ~[]);
assert!(iter::flat_map_to_vec(&Some(1u), incd_if_even) == ~[]);
assert!(iter::flat_map_to_vec(&Some(2u), incd_if_even) == ~[3u]);
assert!(old_iter::flat_map_to_vec(&None::<uint>, incd_if_even) == ~[]);
assert!(old_iter::flat_map_to_vec(&Some(1u), incd_if_even) == ~[]);
assert!(old_iter::flat_map_to_vec(&Some(2u), incd_if_even) == ~[3u]);
}

View file

@ -13,7 +13,7 @@ fn add(x: &float, y: &uint) -> float { *x + ((*y) as float) }
pub fn main() {
assert!([1u, 3u].foldl(20f, add) == 24f);
assert!([].foldl(20f, add) == 20f);
assert!(iter::foldl(&None::<uint>, 20f, add) == 20f);
assert!(iter::foldl(&Some(1u), 20f, add) == 21f);
assert!(iter::foldl(&Some(2u), 20f, add) == 22f);
assert!(old_iter::foldl(&None::<uint>, 20f, add) == 20f);
assert!(old_iter::foldl(&Some(1u), 20f, add) == 21f);
assert!(old_iter::foldl(&Some(2u), 20f, add) == 22f);
}

View file

@ -13,7 +13,7 @@ fn inc(x: &uint) -> uint { *x + 1 }
pub fn main() {
assert!([1, 3].map_to_vec(inc) == ~[2, 4]);
assert!([1, 2, 3].map_to_vec(inc) == ~[2, 3, 4]);
assert!(iter::map_to_vec(&None::<uint>, inc) == ~[]);
assert!(iter::map_to_vec(&Some(1u), inc) == ~[2]);
assert!(iter::map_to_vec(&Some(2u), inc) == ~[3]);
assert!(old_iter::map_to_vec(&None::<uint>, inc) == ~[]);
assert!(old_iter::map_to_vec(&Some(1u), inc) == ~[2]);
assert!(old_iter::map_to_vec(&Some(2u), inc) == ~[3]);
}

View file

@ -13,9 +13,9 @@ fn is_even(&&x: uint) -> bool { (x % 2u) == 0u }
pub fn main() {
assert!([1u, 3u].min() == 1u);
assert!([3u, 1u].min() == 1u);
assert!(iter::min(&Some(1u)) == 1u);
assert!(old_iter::min(&Some(1u)) == 1u);
assert!([1u, 3u].max() == 3u);
assert!([3u, 1u].max() == 3u);
assert!(iter::max(&Some(3u)) == 3u);
assert!(old_iter::max(&Some(3u)) == 3u);
}

View file

@ -12,7 +12,7 @@ pub fn main() {
assert!([1u, 3u].to_vec() == ~[1u, 3u]);
let e: ~[uint] = ~[];
assert!(e.to_vec() == ~[]);
assert!(iter::to_vec(&None::<uint>) == ~[]);
assert!(iter::to_vec(&Some(1u)) == ~[1u]);
assert!(iter::to_vec(&Some(2u)) == ~[2u]);
assert!(old_iter::to_vec(&None::<uint>) == ~[]);
assert!(old_iter::to_vec(&Some(1u)) == ~[1u]);
assert!(old_iter::to_vec(&Some(2u)) == ~[2u]);
}