diff --git a/doc/tutorial.md b/doc/tutorial.md index c757329a45f06..0665187696397 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1981,7 +1981,7 @@ struct TimeBomb { impl Drop for TimeBomb { fn finalize(&self) { - for iter::repeat(self.explosivity) { + for old_iter::repeat(self.explosivity) { io::println("blam!"); } } diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index e2bce1bd0f01a..6ce1acf59472c 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -12,7 +12,7 @@ use cast::transmute; use kinds::Copy; -use iter; +use old_iter; use option::Option; use ptr::addr_of; use sys; @@ -125,7 +125,7 @@ pub fn map(v: &[T], f: &fn(x: &T) -> U) -> @[U] { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value returned by the function `op`. */ -pub fn from_fn(n_elts: uint, op: iter::InitOp) -> @[T] { +pub fn from_fn(n_elts: uint, op: old_iter::InitOp) -> @[T] { do build_sized(n_elts) |push| { let mut i: uint = 0u; while i < n_elts { push(op(i)); i += 1u; } diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 158da9a12fca1..dc3cd03dc2078 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -99,9 +99,10 @@ pub use container::{Container, Mutable}; pub use vec::{CopyableVector, ImmutableVector}; pub use vec::{ImmutableEqVector, ImmutableCopyableVector}; pub use vec::{OwnedVector, OwnedCopyableVector, MutableVector}; -pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter}; -pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times}; -pub use iter::{ExtendedMutableIter}; +pub use old_iter::{BaseIter, ExtendedIter, EqIter, CopyableIter}; +pub use old_iter::{CopyableOrderedIter, CopyableNonstrictIter}; +pub use old_iter::{ExtendedMutableIter}; +pub use iter::Times; pub use num::{Num, NumCast}; pub use num::{Orderable, Signed, Unsigned, Integer}; @@ -188,6 +189,7 @@ pub mod from_str; #[path = "num/num.rs"] pub mod num; pub mod iter; +pub mod old_iter; pub mod iterator; pub mod to_str; pub mod to_bytes; diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index d2be0416371be..41f4f34dc1971 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -16,9 +16,9 @@ use container::{Container, Mutable, Map, Set}; use cmp::{Eq, Equiv}; use hash::Hash; -use iter::BaseIter; +use old_iter::BaseIter; use hash::Hash; -use iter; +use old_iter; use option::{None, Option, Some}; use rand::RngUtil; use rand; @@ -757,12 +757,12 @@ impl Set for HashSet { /// Return true if the set has no elements in common with `other`. /// This is equivalent to checking for an empty intersection. fn is_disjoint(&self, other: &HashSet) -> bool { - iter::all(self, |v| !other.contains(v)) + old_iter::all(self, |v| !other.contains(v)) } /// Return true if the set is a subset of another fn is_subset(&self, other: &HashSet) -> bool { - iter::all(self, |v| other.contains(v)) + old_iter::all(self, |v| other.contains(v)) } /// Return true if the set is a superset of another diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 3dcca0e06c228..7476531ef944c 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -8,369 +8,124 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! +/*! Composable internal iterators -The iteration traits and common implementation +Internal iterators are functions implementing the protocol used by the `for` loop. -*/ - -use cmp::{Eq, Ord}; -use kinds::Copy; -use option::{None, Option, Some}; -use vec; +An internal iterator takes `fn(...) -> bool` as a parameter, with returning `false` used to signal +breaking out of iteration. The adaptors in the module work with any such iterator, not just ones +tied to specific traits. For example: -/// A function used to initialize the elements of a sequence -pub type InitOp<'self,T> = &'self fn(uint) -> T; - -pub trait BaseIter { - fn each(&self, blk: &fn(v: &A) -> bool); - fn size_hint(&self) -> Option; -} +~~~~ +use core::iter::iter_to_vec; +println(iter_to_vec(|f| uint::range(0, 20, f)).to_str()); +~~~~ -pub trait ReverseIter: BaseIter { - fn each_reverse(&self, blk: &fn(&A) -> bool); -} +An external iterator object implementing the interface in the `iterator` module can be used as an +internal iterator by calling the `advance` method. For example: -pub trait MutableIter: BaseIter { - fn each_mut(&mut self, blk: &fn(&mut A) -> bool); -} +~~~~ +use core::iterator::*; -pub trait ExtendedIter { - fn eachi(&self, blk: &fn(uint, v: &A) -> bool); - fn all(&self, blk: &fn(&A) -> bool) -> bool; - fn any(&self, blk: &fn(&A) -> bool) -> bool; - fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B; - fn position(&self, f: &fn(&A) -> bool) -> Option; - fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B]; - fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B]; +let xs = [0u, 1, 2, 3, 4, 5]; +let ys = [30, 40, 50, 60]; +let mut it = xs.iter().chain(ys.iter()); +for it.advance |&x: &uint| { + println(x.to_str()); } +~~~~ -pub trait ExtendedMutableIter { - fn eachi_mut(&mut self, blk: &fn(uint, &mut A) -> bool); -} +Internal iterators provide a subset of the functionality of an external iterator. It's not possible +to interleave them to implement algorithms like `zip`, `union` and `merge`. However, they're often +much easier to implement. -pub trait EqIter { - fn contains(&self, x: &A) -> bool; - fn count(&self, x: &A) -> uint; -} +*/ pub trait Times { fn times(&self, it: &fn() -> bool); } -pub trait CopyableIter { - fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A]; - fn to_vec(&self) -> ~[A]; - fn find(&self, p: &fn(&A) -> bool) -> Option; -} - -pub trait CopyableOrderedIter { - fn min(&self) -> A; - fn max(&self) -> A; -} - -pub trait CopyableNonstrictIter { - // Like "each", but copies out the value. If the receiver is mutated while - // iterating over it, the semantics must not be memory-unsafe but are - // otherwise undefined. - fn each_val(&const self, f: &fn(A) -> bool); -} - -// A trait for sequences that can be built by imperatively pushing elements -// onto them. -pub trait Buildable { - /** - * Builds a buildable sequence by calling a provided function with - * an argument function that pushes an element onto the back of - * the sequence. - * This version takes an initial size for the sequence. - * - * # Arguments - * - * * size - A hint for an initial size of the sequence - * * builder - A function that will construct the sequence. It receives - * as an argument a function that will push an element - * onto the sequence being constructed. - */ - fn build_sized(size: uint, builder: &fn(push: &fn(A))) -> Self; -} - -#[inline(always)] -pub fn eachi>(self: &IA, blk: &fn(uint, &A) -> bool) { - let mut i = 0; - for self.each |a| { - if !blk(i, a) { break; } - i += 1; - } -} - -#[inline(always)] -pub fn all>(self: &IA, blk: &fn(&A) -> bool) -> bool { - for self.each |a| { - if !blk(a) { return false; } - } - return true; -} - -#[inline(always)] -pub fn any>(self: &IA, blk: &fn(&A) -> bool) -> bool { - for self.each |a| { - if blk(a) { return true; } - } - return false; -} - -#[inline(always)] -pub fn filter_to_vec>(self: &IA, - prd: &fn(&A) -> bool) - -> ~[A] { - do vec::build_sized_opt(self.size_hint()) |push| { - for self.each |a| { - if prd(a) { push(*a); } - } - } -} - -#[inline(always)] -pub fn map_to_vec>(self: &IA, op: &fn(&A) -> B) -> ~[B] { - do vec::build_sized_opt(self.size_hint()) |push| { - for self.each |a| { - push(op(a)); - } - } -} - -#[inline(always)] -pub fn flat_map_to_vec,IB:BaseIter>(self: &IA, - op: &fn(&A) -> IB) - -> ~[B] { - do vec::build |push| { - for self.each |a| { - for op(a).each |&b| { - push(b); - } - } - } -} - -#[inline(always)] -pub fn foldl>(self: &IA, b0: B, blk: &fn(&B, &A) -> B) - -> B { - let mut b = b0; - for self.each |a| { - b = blk(&b, a); - } - b -} - -#[inline(always)] -pub fn to_vec>(self: &IA) -> ~[A] { - map_to_vec(self, |&x| x) -} - -#[inline(always)] -pub fn contains>(self: &IA, x: &A) -> bool { - for self.each |a| { - if *a == *x { return true; } - } - return false; -} - -#[inline(always)] -pub fn count>(self: &IA, x: &A) -> uint { - do foldl(self, 0) |count, value| { - if *value == *x { - *count + 1 - } else { - *count - } - } -} - -#[inline(always)] -pub fn position>(self: &IA, f: &fn(&A) -> bool) - -> Option { - let mut i = 0; - for self.each |a| { - if f(a) { return Some(i); } - i += 1; - } - return None; -} - -// note: 'rposition' would only make sense to provide with a bidirectional -// iter interface, such as would provide "reach" in addition to "each". As is, -// it would have to be implemented with foldr, which is too inefficient. - -#[inline(always)] -pub fn repeat(times: uint, blk: &fn() -> bool) { - let mut i = 0; - while i < times { - if !blk() { break } - i += 1; - } -} - -#[inline(always)] -pub fn min>(self: &IA) -> A { - match do foldl::,IA>(self, None) |a, b| { - match a { - &Some(ref a_) if *a_ < *b => { - *(a) - } - _ => Some(*b) - } - } { - Some(val) => val, - None => fail!(~"min called on empty iterator") - } -} - -#[inline(always)] -pub fn max>(self: &IA) -> A { - match do foldl::,IA>(self, None) |a, b| { - match a { - &Some(ref a_) if *a_ > *b => { - *(a) - } - _ => Some(*b) - } - } { - Some(val) => val, - None => fail!(~"max called on empty iterator") - } -} - -#[inline(always)] -pub fn find>(self: &IA, f: &fn(&A) -> bool) - -> Option { - for self.each |i| { - if f(i) { return Some(*i) } - } - return None; -} - -// Some functions for just building - /** - * Builds a sequence by calling a provided function with an argument - * function that pushes an element to the back of a sequence. + * Transform an internal iterator into an owned vector. * - * # Arguments + * # Example: * - * * builder - A function that will construct the sequence. It receives - * as an argument a function that will push an element - * onto the sequence being constructed. + * ~~~ + * let xs = ~[1, 2, 3]; + * let ys = do iter_to_vec |f| { xs.each(|x| f(*x)) }; + * assert_eq!(xs, ys); + * ~~~ */ #[inline(always)] -pub fn build>(builder: &fn(push: &fn(A))) -> B { - Buildable::build_sized(4, builder) +pub fn iter_to_vec(iter: &fn(f: &fn(T) -> bool)) -> ~[T] { + let mut v = ~[]; + for iter |x| { v.push(x) } + v } /** - * Builds a sequence by calling a provided function with an argument - * function that pushes an element to the back of the sequence. - * This version takes an initial size for the sequence. + * Return true if `predicate` is true for any values yielded by an internal iterator. * - * # Arguments + * Example: * - * * size - An option, maybe containing initial size of the sequence - * to reserve. - * * builder - A function that will construct the sequence. It receives - * as an argument a function that will push an element - * onto the sequence being constructed. + * ~~~~ + * let xs = ~[1u, 2, 3, 4, 5]; + * assert!(any(|&x: &uint| x > 2, |f| xs.each(f))); + * assert!(!any(|&x: &uint| x > 5, |f| xs.each(f))); + * ~~~~ */ #[inline(always)] -pub fn build_sized_opt>(size: Option, - builder: &fn(push: &fn(A))) -> B { - Buildable::build_sized(size.get_or_default(4), builder) -} - -// Functions that combine iteration and building - -/// Applies a function to each element of an iterable and returns the results -/// in a sequence built via `BU`. See also `map_to_vec`. -#[inline(always)] -pub fn map,U,BU: Buildable>(v: &IT, f: &fn(&T) -> U) - -> BU { - do build_sized_opt(v.size_hint()) |push| { - for v.each() |elem| { - push(f(elem)); +pub fn any(predicate: &fn(T) -> bool, iter: &fn(f: &fn(T) -> bool)) -> bool { + for iter |x| { + if predicate(x) { + return true } } + false } /** - * Creates and initializes a generic sequence from a function. + * Return true if `predicate` is true for all values yielded by an internal iterator. * - * Creates a generic sequence of size `n_elts` and initializes the elements - * to the value returned by the function `op`. - */ -#[inline(always)] -pub fn from_fn>(n_elts: uint, op: InitOp) -> BT { - do Buildable::build_sized(n_elts) |push| { - let mut i: uint = 0u; - while i < n_elts { push(op(i)); i += 1u; } - } -} - -/** - * Creates and initializes a generic sequence with some elements. + * # Example: * - * Creates an immutable vector of size `n_elts` and initializes the elements - * to the value `t`. + * ~~~~ + * assert!(all(|&x: &uint| x < 6, |f| uint::range(1, 6, f))); + * assert!(!all(|&x: &uint| x < 5, |f| uint::range(1, 6, f))); + * ~~~~ */ #[inline(always)] -pub fn from_elem>(n_elts: uint, t: T) -> BT { - do Buildable::build_sized(n_elts) |push| { - let mut i: uint = 0; - while i < n_elts { push(t); i += 1; } +pub fn all(predicate: &fn(T) -> bool, iter: &fn(f: &fn(T) -> bool)) -> bool { + for iter |x| { + if !predicate(x) { + return false + } } + true } -/// Appends two generic sequences. -#[inline(always)] -pub fn append,BT:Buildable>(lhs: &IT, rhs: &IT) - -> BT { - let size_opt = lhs.size_hint().chain_ref( - |sz1| rhs.size_hint().map(|sz2| *sz1+*sz2)); - do build_sized_opt(size_opt) |push| { - for lhs.each |x| { push(*x); } - for rhs.each |x| { push(*x); } - } -} +#[cfg(test)] +mod tests { + use super::*; + use prelude::*; -/// Copies a generic sequence, possibly converting it to a different -/// type of sequence. -#[inline(always)] -pub fn copy_seq,BT:Buildable>(v: &IT) -> BT { - do build_sized_opt(v.size_hint()) |push| { - for v.each |x| { push(*x); } + #[test] + fn test_iter_to_vec() { + let xs = ~[1, 2, 3]; + let ys = do iter_to_vec |f| { xs.each(|x| f(*x)) }; + assert_eq!(xs, ys); } -} -/** - * Helper function to transform an internal iterator into an owned vector. - * - * # Example: - * - * ~~~ - * let v = ~[1, 2, 3]; - * let v2 = do iter_to_vec |f| { v.each(|e| f(*e)) }; - * if v != v2 { fail!() } - * ~~~ - */ -#[inline(always)] -pub fn iter_to_vec(pusher: &fn(it: &fn(T) -> bool)) -> ~[T] { - let mut v = ~[]; - let pushf = |e| {v.push(e); true}; - pusher(pushf); - v -} + #[test] + fn test_any() { + let xs = ~[1u, 2, 3, 4, 5]; + assert!(any(|&x: &uint| x > 2, |f| xs.each(f))); + assert!(!any(|&x: &uint| x > 5, |f| xs.each(f))); + } -#[test] -fn test_iter_to_vec() { - let v = ~[1, 2, 3]; - let v2 = do iter_to_vec |f| { v.each(|e| f(*e)) }; - if v != v2 { fail!() } + #[test] + fn test_all() { + assert!(all(|x: uint| x < 6, |f| uint::range(1, 6, f))); + assert!(!all(|x: uint| x < 5, |f| uint::range(1, 6, f))); + } } diff --git a/src/libcore/num/uint-template/uint.rs b/src/libcore/num/uint-template/uint.rs index 6a8567451e6e0..de882f1ee7a1f 100644 --- a/src/libcore/num/uint-template/uint.rs +++ b/src/libcore/num/uint-template/uint.rs @@ -16,9 +16,9 @@ pub use self::inst::{ }; pub mod inst { - use sys; use iter; use num::{Primitive, BitCount}; + use sys; pub type T = uint; #[allow(non_camel_case_types)] diff --git a/src/libcore/old_iter.rs b/src/libcore/old_iter.rs new file mode 100644 index 0000000000000..98b847c75b408 --- /dev/null +++ b/src/libcore/old_iter.rs @@ -0,0 +1,346 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/*! + +**Deprecated** iteration traits and common implementations. + +*/ + +use cmp::{Eq, Ord}; +use kinds::Copy; +use option::{None, Option, Some}; +use vec; + +/// A function used to initialize the elements of a sequence +pub type InitOp<'self,T> = &'self fn(uint) -> T; + +pub trait BaseIter { + fn each(&self, blk: &fn(v: &A) -> bool); + fn size_hint(&self) -> Option; +} + +pub trait ReverseIter: BaseIter { + fn each_reverse(&self, blk: &fn(&A) -> bool); +} + +pub trait MutableIter: BaseIter { + fn each_mut(&mut self, blk: &fn(&mut A) -> bool); +} + +pub trait ExtendedIter { + fn eachi(&self, blk: &fn(uint, v: &A) -> bool); + fn all(&self, blk: &fn(&A) -> bool) -> bool; + fn any(&self, blk: &fn(&A) -> bool) -> bool; + fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B; + fn position(&self, f: &fn(&A) -> bool) -> Option; + fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B]; + fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B]; +} + +pub trait ExtendedMutableIter { + fn eachi_mut(&mut self, blk: &fn(uint, &mut A) -> bool); +} + +pub trait EqIter { + fn contains(&self, x: &A) -> bool; + fn count(&self, x: &A) -> uint; +} + +pub trait CopyableIter { + fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A]; + fn to_vec(&self) -> ~[A]; + fn find(&self, p: &fn(&A) -> bool) -> Option; +} + +pub trait CopyableOrderedIter { + fn min(&self) -> A; + fn max(&self) -> A; +} + +pub trait CopyableNonstrictIter { + // Like "each", but copies out the value. If the receiver is mutated while + // iterating over it, the semantics must not be memory-unsafe but are + // otherwise undefined. + fn each_val(&const self, f: &fn(A) -> bool); +} + +// A trait for sequences that can be built by imperatively pushing elements +// onto them. +pub trait Buildable { + /** + * Builds a buildable sequence by calling a provided function with + * an argument function that pushes an element onto the back of + * the sequence. + * This version takes an initial size for the sequence. + * + * # Arguments + * + * * size - A hint for an initial size of the sequence + * * builder - A function that will construct the sequence. It receives + * as an argument a function that will push an element + * onto the sequence being constructed. + */ + fn build_sized(size: uint, builder: &fn(push: &fn(A))) -> Self; +} + +#[inline(always)] +pub fn eachi>(self: &IA, blk: &fn(uint, &A) -> bool) { + let mut i = 0; + for self.each |a| { + if !blk(i, a) { break; } + i += 1; + } +} + +#[inline(always)] +pub fn all>(self: &IA, blk: &fn(&A) -> bool) -> bool { + for self.each |a| { + if !blk(a) { return false; } + } + return true; +} + +#[inline(always)] +pub fn any>(self: &IA, blk: &fn(&A) -> bool) -> bool { + for self.each |a| { + if blk(a) { return true; } + } + return false; +} + +#[inline(always)] +pub fn filter_to_vec>(self: &IA, + prd: &fn(&A) -> bool) + -> ~[A] { + do vec::build_sized_opt(self.size_hint()) |push| { + for self.each |a| { + if prd(a) { push(*a); } + } + } +} + +#[inline(always)] +pub fn map_to_vec>(self: &IA, op: &fn(&A) -> B) -> ~[B] { + do vec::build_sized_opt(self.size_hint()) |push| { + for self.each |a| { + push(op(a)); + } + } +} + +#[inline(always)] +pub fn flat_map_to_vec,IB:BaseIter>(self: &IA, + op: &fn(&A) -> IB) + -> ~[B] { + do vec::build |push| { + for self.each |a| { + for op(a).each |&b| { + push(b); + } + } + } +} + +#[inline(always)] +pub fn foldl>(self: &IA, b0: B, blk: &fn(&B, &A) -> B) + -> B { + let mut b = b0; + for self.each |a| { + b = blk(&b, a); + } + b +} + +#[inline(always)] +pub fn to_vec>(self: &IA) -> ~[A] { + map_to_vec(self, |&x| x) +} + +#[inline(always)] +pub fn contains>(self: &IA, x: &A) -> bool { + for self.each |a| { + if *a == *x { return true; } + } + return false; +} + +#[inline(always)] +pub fn count>(self: &IA, x: &A) -> uint { + do foldl(self, 0) |count, value| { + if *value == *x { + *count + 1 + } else { + *count + } + } +} + +#[inline(always)] +pub fn position>(self: &IA, f: &fn(&A) -> bool) + -> Option { + let mut i = 0; + for self.each |a| { + if f(a) { return Some(i); } + i += 1; + } + return None; +} + +// note: 'rposition' would only make sense to provide with a bidirectional +// iter interface, such as would provide "reach" in addition to "each". As is, +// it would have to be implemented with foldr, which is too inefficient. + +#[inline(always)] +pub fn repeat(times: uint, blk: &fn() -> bool) { + let mut i = 0; + while i < times { + if !blk() { break } + i += 1; + } +} + +#[inline(always)] +pub fn min>(self: &IA) -> A { + match do foldl::,IA>(self, None) |a, b| { + match a { + &Some(ref a_) if *a_ < *b => { + *(a) + } + _ => Some(*b) + } + } { + Some(val) => val, + None => fail!(~"min called on empty iterator") + } +} + +#[inline(always)] +pub fn max>(self: &IA) -> A { + match do foldl::,IA>(self, None) |a, b| { + match a { + &Some(ref a_) if *a_ > *b => { + *(a) + } + _ => Some(*b) + } + } { + Some(val) => val, + None => fail!(~"max called on empty iterator") + } +} + +#[inline(always)] +pub fn find>(self: &IA, f: &fn(&A) -> bool) + -> Option { + for self.each |i| { + if f(i) { return Some(*i) } + } + return None; +} + +// Some functions for just building + +/** + * Builds a sequence by calling a provided function with an argument + * function that pushes an element to the back of a sequence. + * + * # Arguments + * + * * builder - A function that will construct the sequence. It receives + * as an argument a function that will push an element + * onto the sequence being constructed. + */ +#[inline(always)] +pub fn build>(builder: &fn(push: &fn(A))) -> B { + Buildable::build_sized(4, builder) +} + +/** + * Builds a sequence by calling a provided function with an argument + * function that pushes an element to the back of the sequence. + * This version takes an initial size for the sequence. + * + * # Arguments + * + * * size - An option, maybe containing initial size of the sequence + * to reserve. + * * builder - A function that will construct the sequence. It receives + * as an argument a function that will push an element + * onto the sequence being constructed. + */ +#[inline(always)] +pub fn build_sized_opt>(size: Option, + builder: &fn(push: &fn(A))) -> B { + Buildable::build_sized(size.get_or_default(4), builder) +} + +// Functions that combine iteration and building + +/// Applies a function to each element of an iterable and returns the results +/// in a sequence built via `BU`. See also `map_to_vec`. +#[inline(always)] +pub fn map,U,BU: Buildable>(v: &IT, f: &fn(&T) -> U) + -> BU { + do build_sized_opt(v.size_hint()) |push| { + for v.each() |elem| { + push(f(elem)); + } + } +} + +/** + * Creates and initializes a generic sequence from a function. + * + * Creates a generic sequence of size `n_elts` and initializes the elements + * to the value returned by the function `op`. + */ +#[inline(always)] +pub fn from_fn>(n_elts: uint, op: InitOp) -> BT { + do Buildable::build_sized(n_elts) |push| { + let mut i: uint = 0u; + while i < n_elts { push(op(i)); i += 1u; } + } +} + +/** + * Creates and initializes a generic sequence with some elements. + * + * Creates an immutable vector of size `n_elts` and initializes the elements + * to the value `t`. + */ +#[inline(always)] +pub fn from_elem>(n_elts: uint, t: T) -> BT { + do Buildable::build_sized(n_elts) |push| { + let mut i: uint = 0; + while i < n_elts { push(t); i += 1; } + } +} + +/// Appends two generic sequences. +#[inline(always)] +pub fn append,BT:Buildable>(lhs: &IT, rhs: &IT) + -> BT { + let size_opt = lhs.size_hint().chain_ref( + |sz1| rhs.size_hint().map(|sz2| *sz1+*sz2)); + do build_sized_opt(size_opt) |push| { + for lhs.each |x| { push(*x); } + for rhs.each |x| { push(*x); } + } +} + +/// Copies a generic sequence, possibly converting it to a different +/// type of sequence. +#[inline(always)] +pub fn copy_seq,BT:Buildable>(v: &IT) -> BT { + do build_sized_opt(v.size_hint()) |push| { + for v.each |x| { push(*x); } + } +} diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 9b7276879c123..d3519854a0a36 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -46,8 +46,8 @@ use ops::Add; use kinds::Copy; use util; use num::Zero; -use iter::{BaseIter, MutableIter, ExtendedIter}; -use iter; +use old_iter::{BaseIter, MutableIter, ExtendedIter}; +use old_iter; #[cfg(test)] use ptr; #[cfg(test)] use str; @@ -140,26 +140,26 @@ impl MutableIter for Option { impl ExtendedIter for Option { pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { - iter::eachi(self, blk) + old_iter::eachi(self, blk) } pub fn all(&self, blk: &fn(&A) -> bool) -> bool { - iter::all(self, blk) + old_iter::all(self, blk) } pub fn any(&self, blk: &fn(&A) -> bool) -> bool { - iter::any(self, blk) + old_iter::any(self, blk) } pub fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { - iter::foldl(self, b0, blk) + old_iter::foldl(self, b0, blk) } pub fn position(&self, f: &fn(&A) -> bool) -> Option { - iter::position(self, f) + old_iter::position(self, f) } fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { - iter::map_to_vec(self, op) + old_iter::map_to_vec(self, op) } fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { - iter::flat_map_to_vec(self, op) + old_iter::flat_map_to_vec(self, op) } } diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index 7e41f1b5b34e2..41078fb8920a7 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -34,9 +34,10 @@ pub use clone::Clone; pub use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater}; pub use container::{Container, Mutable, Map, Set}; pub use hash::Hash; -pub use iter::{BaseIter, ReverseIter, MutableIter, ExtendedIter, EqIter}; -pub use iter::{CopyableIter, CopyableOrderedIter, CopyableNonstrictIter}; -pub use iter::{Times, ExtendedMutableIter}; +pub use old_iter::{BaseIter, ReverseIter, MutableIter, ExtendedIter, EqIter}; +pub use old_iter::{CopyableIter, CopyableOrderedIter, CopyableNonstrictIter}; +pub use old_iter::{ExtendedMutableIter}; +pub use iter::Times; pub use num::{Num, NumCast}; pub use num::{Orderable, Signed, Unsigned, Integer}; pub use num::{Round, Fractional, Real, RealExt}; @@ -79,6 +80,7 @@ pub use i8; pub use int; pub use io; pub use iter; +pub use old_iter; pub use libc; pub use num; pub use ops; diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index a6c03638713ed..2163a0e325f13 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -687,7 +687,7 @@ fn test_spawn_unlinked_unsup_no_fail_down() { // grandchild sends on a port let ch = ch.clone(); do spawn_unlinked { // Give middle task a chance to fail-but-not-kill-us. - for iter::repeat(16) { task::yield(); } + for old_iter::repeat(16) { task::yield(); } ch.send(()); // If killed first, grandparent hangs. } fail!(); // Shouldn't kill either (grand)parent or (grand)child. @@ -702,7 +702,7 @@ fn test_spawn_unlinked_unsup_no_fail_up() { // child unlinked fails fn test_spawn_unlinked_sup_no_fail_up() { // child unlinked fails do spawn_supervised { fail!(); } // Give child a chance to fail-but-not-kill-us. - for iter::repeat(16) { task::yield(); } + for old_iter::repeat(16) { task::yield(); } } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_spawn_unlinked_sup_fail_down() { @@ -783,7 +783,7 @@ fn test_spawn_failure_propagate_grandchild() { loop { task::yield(); } } } - for iter::repeat(16) { task::yield(); } + for old_iter::repeat(16) { task::yield(); } fail!(); } @@ -795,7 +795,7 @@ fn test_spawn_failure_propagate_secondborn() { loop { task::yield(); } } } - for iter::repeat(16) { task::yield(); } + for old_iter::repeat(16) { task::yield(); } fail!(); } @@ -807,7 +807,7 @@ fn test_spawn_failure_propagate_nephew_or_niece() { loop { task::yield(); } } } - for iter::repeat(16) { task::yield(); } + for old_iter::repeat(16) { task::yield(); } fail!(); } @@ -819,7 +819,7 @@ fn test_spawn_linked_sup_propagate_sibling() { loop { task::yield(); } } } - for iter::repeat(16) { task::yield(); } + for old_iter::repeat(16) { task::yield(); } fail!(); } @@ -971,7 +971,7 @@ fn test_spawn_sched_blocking() { // Testing that a task in one scheduler can block in foreign code // without affecting other schedulers - for iter::repeat(20u) { + for old_iter::repeat(20u) { let (start_po, start_ch) = stream(); let (fin_po, fin_ch) = stream(); @@ -1088,7 +1088,7 @@ fn test_unkillable() { // We want to do this after failing do spawn_unlinked { - for iter::repeat(10) { yield() } + for old_iter::repeat(10) { yield() } ch.send(()); } @@ -1123,7 +1123,7 @@ fn test_unkillable_nested() { // We want to do this after failing do spawn_unlinked || { - for iter::repeat(10) { yield() } + for old_iter::repeat(10) { yield() } ch.send(()); } diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 176e20f38944d..ef42647411a34 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -17,8 +17,8 @@ use cast; use container::{Container, Mutable}; use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater}; use clone::Clone; -use iter::BaseIter; -use iter; +use old_iter::BaseIter; +use old_iter; #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] @@ -142,7 +142,7 @@ pub fn uniq_len(v: &const ~[T]) -> uint { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value returned by the function `op`. */ -pub fn from_fn(n_elts: uint, op: iter::InitOp) -> ~[T] { +pub fn from_fn(n_elts: uint, op: old_iter::InitOp) -> ~[T] { unsafe { let mut v = with_capacity(n_elts); do as_mut_buf(v) |p, _len| { @@ -786,7 +786,7 @@ pub fn grow(v: &mut ~[T], n: uint, initval: &T) { * * init_op - A function to call to retreive each appended element's * value */ -pub fn grow_fn(v: &mut ~[T], n: uint, op: iter::InitOp) { +pub fn grow_fn(v: &mut ~[T], n: uint, op: old_iter::InitOp) { let new_len = v.len() + n; reserve_at_least(&mut *v, new_len); let mut i: uint = 0u; @@ -2265,7 +2265,7 @@ pub trait OwnedVector { fn consume_reverse(self, f: &fn(uint, v: T)); fn filter(self, f: &fn(t: &T) -> bool) -> ~[T]; fn partition(self, f: &fn(&T) -> bool) -> (~[T], ~[T]); - fn grow_fn(&mut self, n: uint, op: iter::InitOp); + fn grow_fn(&mut self, n: uint, op: old_iter::InitOp); } impl OwnedVector for ~[T] { @@ -2344,7 +2344,7 @@ impl OwnedVector for ~[T] { } #[inline] - fn grow_fn(&mut self, n: uint, op: iter::InitOp) { + fn grow_fn(&mut self, n: uint, op: old_iter::InitOp) { grow_fn(self, n, op); } } @@ -2643,7 +2643,7 @@ pub mod bytes { // ITERATION TRAIT METHODS #[cfg(stage0)] -impl<'self,A> iter::BaseIter for &'self [A] { +impl<'self,A> old_iter::BaseIter for &'self [A] { #[inline(always)] fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } #[inline(always)] @@ -2653,7 +2653,7 @@ impl<'self,A> iter::BaseIter for &'self [A] { #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] -impl<'self,A> iter::BaseIter for &'self [A] { +impl<'self,A> old_iter::BaseIter for &'self [A] { #[inline(always)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) { each(*self, blk) } #[inline(always)] @@ -2662,7 +2662,7 @@ impl<'self,A> iter::BaseIter for &'self [A] { // FIXME(#4148): This should be redundant #[cfg(stage0)] -impl iter::BaseIter for ~[A] { +impl old_iter::BaseIter for ~[A] { #[inline(always)] fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } #[inline(always)] @@ -2673,7 +2673,7 @@ impl iter::BaseIter for ~[A] { #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] -impl iter::BaseIter for ~[A] { +impl old_iter::BaseIter for ~[A] { #[inline(always)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) { each(*self, blk) } #[inline(always)] @@ -2682,7 +2682,7 @@ impl iter::BaseIter for ~[A] { // FIXME(#4148): This should be redundant #[cfg(stage0)] -impl iter::BaseIter for @[A] { +impl old_iter::BaseIter for @[A] { #[inline(always)] fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } #[inline(always)] @@ -2693,7 +2693,7 @@ impl iter::BaseIter for @[A] { #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] -impl iter::BaseIter for @[A] { +impl old_iter::BaseIter for @[A] { #[inline(always)] fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) { each(*self, blk) } #[inline(always)] @@ -2701,7 +2701,7 @@ impl iter::BaseIter for @[A] { } #[cfg(stage0)] -impl<'self,A> iter::MutableIter for &'self mut [A] { +impl<'self,A> old_iter::MutableIter for &'self mut [A] { #[inline(always)] fn each_mut(&mut self, blk: &fn(v: &'self mut A) -> bool) { each_mut(*self, blk) @@ -2711,7 +2711,7 @@ impl<'self,A> iter::MutableIter for &'self mut [A] { #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] -impl<'self,A> iter::MutableIter for &'self mut [A] { +impl<'self,A> old_iter::MutableIter for &'self mut [A] { #[inline(always)] fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) { each_mut(*self, blk) @@ -2720,7 +2720,7 @@ impl<'self,A> iter::MutableIter for &'self mut [A] { // FIXME(#4148): This should be redundant #[cfg(stage0)] -impl iter::MutableIter for ~[A] { +impl old_iter::MutableIter for ~[A] { #[inline(always)] fn each_mut(&mut self, blk: &fn(v: &'self mut A) -> bool) { each_mut(*self, blk) @@ -2730,7 +2730,7 @@ impl iter::MutableIter for ~[A] { #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)] -impl iter::MutableIter for ~[A] { +impl old_iter::MutableIter for ~[A] { #[inline(always)] fn each_mut<'a>(&'a mut self, blk: &fn(v: &'a mut A) -> bool) { each_mut(*self, blk) @@ -2738,39 +2738,39 @@ impl iter::MutableIter for ~[A] { } // FIXME(#4148): This should be redundant -impl iter::MutableIter for @mut [A] { +impl old_iter::MutableIter for @mut [A] { #[inline(always)] fn each_mut(&mut self, blk: &fn(v: &mut A) -> bool) { each_mut(*self, blk) } } -impl<'self,A> iter::ExtendedIter for &'self [A] { +impl<'self,A> old_iter::ExtendedIter for &'self [A] { pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { - iter::eachi(self, blk) + old_iter::eachi(self, blk) } pub fn all(&self, blk: &fn(&A) -> bool) -> bool { - iter::all(self, blk) + old_iter::all(self, blk) } pub fn any(&self, blk: &fn(&A) -> bool) -> bool { - iter::any(self, blk) + old_iter::any(self, blk) } pub fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { - iter::foldl(self, b0, blk) + old_iter::foldl(self, b0, blk) } pub fn position(&self, f: &fn(&A) -> bool) -> Option { - iter::position(self, f) + old_iter::position(self, f) } fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { - iter::map_to_vec(self, op) + old_iter::map_to_vec(self, op) } fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { - iter::flat_map_to_vec(self, op) + old_iter::flat_map_to_vec(self, op) } } -impl<'self,A> iter::ExtendedMutableIter for &'self mut [A] { +impl<'self,A> old_iter::ExtendedMutableIter for &'self mut [A] { #[inline(always)] pub fn eachi_mut(&mut self, blk: &fn(uint, v: &mut A) -> bool) { eachi_mut(*self, blk) @@ -2778,124 +2778,124 @@ impl<'self,A> iter::ExtendedMutableIter for &'self mut [A] { } // FIXME(#4148): This should be redundant -impl iter::ExtendedIter for ~[A] { +impl old_iter::ExtendedIter for ~[A] { pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { - iter::eachi(self, blk) + old_iter::eachi(self, blk) } pub fn all(&self, blk: &fn(&A) -> bool) -> bool { - iter::all(self, blk) + old_iter::all(self, blk) } pub fn any(&self, blk: &fn(&A) -> bool) -> bool { - iter::any(self, blk) + old_iter::any(self, blk) } pub fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { - iter::foldl(self, b0, blk) + old_iter::foldl(self, b0, blk) } pub fn position(&self, f: &fn(&A) -> bool) -> Option { - iter::position(self, f) + old_iter::position(self, f) } fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { - iter::map_to_vec(self, op) + old_iter::map_to_vec(self, op) } fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { - iter::flat_map_to_vec(self, op) + old_iter::flat_map_to_vec(self, op) } } // FIXME(#4148): This should be redundant -impl iter::ExtendedIter for @[A] { +impl old_iter::ExtendedIter for @[A] { pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { - iter::eachi(self, blk) + old_iter::eachi(self, blk) } pub fn all(&self, blk: &fn(&A) -> bool) -> bool { - iter::all(self, blk) + old_iter::all(self, blk) } pub fn any(&self, blk: &fn(&A) -> bool) -> bool { - iter::any(self, blk) + old_iter::any(self, blk) } pub fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { - iter::foldl(self, b0, blk) + old_iter::foldl(self, b0, blk) } pub fn position(&self, f: &fn(&A) -> bool) -> Option { - iter::position(self, f) + old_iter::position(self, f) } fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { - iter::map_to_vec(self, op) + old_iter::map_to_vec(self, op) } fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { - iter::flat_map_to_vec(self, op) + old_iter::flat_map_to_vec(self, op) } } -impl<'self,A:Eq> iter::EqIter for &'self [A] { - pub fn contains(&self, x: &A) -> bool { iter::contains(self, x) } - pub fn count(&self, x: &A) -> uint { iter::count(self, x) } +impl<'self,A:Eq> old_iter::EqIter for &'self [A] { + pub fn contains(&self, x: &A) -> bool { old_iter::contains(self, x) } + pub fn count(&self, x: &A) -> uint { old_iter::count(self, x) } } // FIXME(#4148): This should be redundant -impl iter::EqIter for ~[A] { - pub fn contains(&self, x: &A) -> bool { iter::contains(self, x) } - pub fn count(&self, x: &A) -> uint { iter::count(self, x) } +impl old_iter::EqIter for ~[A] { + pub fn contains(&self, x: &A) -> bool { old_iter::contains(self, x) } + pub fn count(&self, x: &A) -> uint { old_iter::count(self, x) } } // FIXME(#4148): This should be redundant -impl iter::EqIter for @[A] { - pub fn contains(&self, x: &A) -> bool { iter::contains(self, x) } - pub fn count(&self, x: &A) -> uint { iter::count(self, x) } +impl old_iter::EqIter for @[A] { + pub fn contains(&self, x: &A) -> bool { old_iter::contains(self, x) } + pub fn count(&self, x: &A) -> uint { old_iter::count(self, x) } } -impl<'self,A:Copy> iter::CopyableIter for &'self [A] { +impl<'self,A:Copy> old_iter::CopyableIter for &'self [A] { fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { - iter::filter_to_vec(self, pred) + old_iter::filter_to_vec(self, pred) } - fn to_vec(&self) -> ~[A] { iter::to_vec(self) } + fn to_vec(&self) -> ~[A] { old_iter::to_vec(self) } pub fn find(&self, f: &fn(&A) -> bool) -> Option { - iter::find(self, f) + old_iter::find(self, f) } } // FIXME(#4148): This should be redundant -impl iter::CopyableIter for ~[A] { +impl old_iter::CopyableIter for ~[A] { fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { - iter::filter_to_vec(self, pred) + old_iter::filter_to_vec(self, pred) } - fn to_vec(&self) -> ~[A] { iter::to_vec(self) } + fn to_vec(&self) -> ~[A] { old_iter::to_vec(self) } pub fn find(&self, f: &fn(&A) -> bool) -> Option { - iter::find(self, f) + old_iter::find(self, f) } } // FIXME(#4148): This should be redundant -impl iter::CopyableIter for @[A] { +impl old_iter::CopyableIter for @[A] { fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { - iter::filter_to_vec(self, pred) + old_iter::filter_to_vec(self, pred) } - fn to_vec(&self) -> ~[A] { iter::to_vec(self) } + fn to_vec(&self) -> ~[A] { old_iter::to_vec(self) } pub fn find(&self, f: &fn(&A) -> bool) -> Option { - iter::find(self, f) + old_iter::find(self, f) } } -impl<'self,A:Copy + Ord> iter::CopyableOrderedIter for &'self [A] { - fn min(&self) -> A { iter::min(self) } - fn max(&self) -> A { iter::max(self) } +impl<'self,A:Copy + Ord> old_iter::CopyableOrderedIter for &'self [A] { + fn min(&self) -> A { old_iter::min(self) } + fn max(&self) -> A { old_iter::max(self) } } // FIXME(#4148): This should be redundant -impl iter::CopyableOrderedIter for ~[A] { - fn min(&self) -> A { iter::min(self) } - fn max(&self) -> A { iter::max(self) } +impl old_iter::CopyableOrderedIter for ~[A] { + fn min(&self) -> A { old_iter::min(self) } + fn max(&self) -> A { old_iter::max(self) } } // FIXME(#4148): This should be redundant -impl iter::CopyableOrderedIter for @[A] { - fn min(&self) -> A { iter::min(self) } - fn max(&self) -> A { iter::max(self) } +impl old_iter::CopyableOrderedIter for @[A] { + fn min(&self) -> A { old_iter::min(self) } + fn max(&self) -> A { old_iter::max(self) } } -impl<'self,A:Copy> iter::CopyableNonstrictIter for &'self [A] { +impl<'self,A:Copy> old_iter::CopyableNonstrictIter for &'self [A] { fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; while i < self.len() { @@ -2906,7 +2906,7 @@ impl<'self,A:Copy> iter::CopyableNonstrictIter for &'self [A] { } // FIXME(#4148): This should be redundant -impl iter::CopyableNonstrictIter for ~[A] { +impl old_iter::CopyableNonstrictIter for ~[A] { fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; while i < uniq_len(self) { @@ -2917,7 +2917,7 @@ impl iter::CopyableNonstrictIter for ~[A] { } // FIXME(#4148): This should be redundant -impl iter::CopyableNonstrictIter for @[A] { +impl old_iter::CopyableNonstrictIter for @[A] { fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; while i < self.len() { diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 5cc8cabbb3816..fd836b20b8100 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -1071,7 +1071,7 @@ pub impl Liveness { fn propagate_through_opt_expr(&self, opt_expr: Option<@expr>, succ: LiveNode) -> LiveNode { - do iter::foldl(&opt_expr, succ) |succ, expr| { + do old_iter::foldl(&opt_expr, succ) |succ, expr| { self.propagate_through_expr(*expr, *succ) } } diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 73e4fe6a435bf..14c9bc36d7f7a 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -210,7 +210,7 @@ pub impl CoherenceChecker { match item.node { item_impl(_, opt_trait, _, _) => { self.check_implementation(item, - iter::to_vec(&opt_trait)); + old_iter::to_vec(&opt_trait)); } _ => { // Nothing to do. diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index 3a8116b5ae6b0..16b84190ee391 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -629,7 +629,7 @@ mod test { let doc = (page_pass::mk_pass(config::DocPerMod).f)(srv, doc); write_markdown(doc, writer_factory); // We expect two pages to have been written - for iter::repeat(2) { + for old_iter::repeat(2) { po.recv(); } } @@ -641,7 +641,7 @@ mod test { ~"#[link(name = \"core\")]; mod a { }"); let doc = (page_pass::mk_pass(config::DocPerMod).f)(srv, doc); write_markdown(doc, writer_factory); - for iter::repeat(2) { + for old_iter::repeat(2) { let (page, markdown) = po.recv(); match page { doc::CratePage(_) => { diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index e90f0fb3c81d4..b26296c9acae4 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -10,7 +10,7 @@ //! Base64 binary-to-text encoding -use core::iter; +use core::old_iter; use core::str; use core::vec; @@ -152,7 +152,7 @@ impl FromBase64 for ~[u8] { while i < len { let mut n = 0u; - for iter::repeat(4u) { + for old_iter::repeat(4u) { let ch = self[i] as char; n <<= 6u; diff --git a/src/libstd/dlist.rs b/src/libstd/dlist.rs index 5fdc467cfa2a0..1257d55453205 100644 --- a/src/libstd/dlist.rs +++ b/src/libstd/dlist.rs @@ -483,7 +483,7 @@ pub impl DList { /// Get the elements of the list as a vector. O(n). fn to_vec(@mut self) -> ~[T] { let mut v = vec::with_capacity(self.size); - for iter::eachi(&self) |index,data| { + for old_iter::eachi(&self) |index,data| { v[index] = *data; } v @@ -750,7 +750,7 @@ mod tests { #[test] fn test_dlist_foldl() { let l = from_vec(vec::from_fn(101, |x|x)); - assert_eq!(iter::foldl(&l, 0, |accum,elem| *accum+*elem), 5050); + assert_eq!(old_iter::foldl(&l, 0, |accum,elem| *accum+*elem), 5050); } #[test] fn test_dlist_break_early() { diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index 08a58125d7ea5..60f25c2a270b2 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -10,7 +10,7 @@ //! A priority queue implemented with a binary heap -use core::iter::BaseIter; +use core::old_iter::BaseIter; use core::ptr::addr_of; #[abi = "rust-intrinsic"] diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 487a5598d6f0b..fb17d4e50900c 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -14,7 +14,7 @@ */ use core::container::{Container, Mutable, Map, Set}; -use core::iter::{BaseIter}; +use core::old_iter::{BaseIter}; use core::option::{Some, None}; pub struct SmallIntMap { diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index a36a6da465360..69e01d4e4dbdd 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -183,7 +183,7 @@ mod test { #[test] fn test_gl_timer_sleep_stress1() { let hl_loop = &uv::global_loop::get(); - for iter::repeat(50u) { + for old_iter::repeat(50u) { sleep(hl_loop, 1u); } } @@ -203,7 +203,7 @@ mod test { }; - for iter::repeat(repeat) { + for old_iter::repeat(repeat) { let ch = ch.clone(); for spec.each |spec| { @@ -213,7 +213,7 @@ mod test { do task::spawn { use core::rand::*; let rng = rng(); - for iter::repeat(times) { + for old_iter::repeat(times) { sleep(&hl_loop_clone, rng.next() as uint % maxms); } ch.send(()); @@ -221,7 +221,7 @@ mod test { } } - for iter::repeat(repeat * spec.len()) { + for old_iter::repeat(repeat * spec.len()) { po.recv() } } @@ -239,7 +239,7 @@ mod test { let mut failures = 0; let hl_loop = uv::global_loop::get(); - for iter::repeat(times as uint) { + for old_iter::repeat(times as uint) { task::yield(); let expected = rand::rng().gen_str(16u); @@ -268,7 +268,7 @@ mod test { let mut failures = 0; let hl_loop = uv::global_loop::get(); - for iter::repeat(times as uint) { + for old_iter::repeat(times as uint) { let expected = rand::rng().gen_str(16u); let (test_po, test_ch) = stream::<~str>(); let hl_loop_clone = hl_loop.clone(); diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index a9016697031c5..2ab5ce8698c25 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -119,7 +119,7 @@ mod test { use uv::ll; use uv_iotask::IoTask; - use core::iter; + use core::old_iter; use core::libc; use core::ptr; use core::task; @@ -210,7 +210,7 @@ mod test { let (exit_po, exit_ch) = stream::<()>(); let exit_ch = SharedChan::new(exit_ch); let cycles = 5000u; - for iter::repeat(cycles) { + for old_iter::repeat(cycles) { let exit_ch_clone = exit_ch.clone(); task::spawn_sched(task::ManualThreads(1u), || { let hl_loop = &get_gl(); @@ -218,7 +218,7 @@ mod test { exit_ch_clone.send(()); }); }; - for iter::repeat(cycles) { + for old_iter::repeat(cycles) { exit_po.recv(); }; debug!(~"test_stress_gl_uv_global_loop_high_level_global_timer"+ diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index f03c60757f334..309ae32dc59af 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -285,7 +285,7 @@ fn test_uv_iotask_async() { // impl_uv_hl_async() runs have been called, at least. let (work_exit_po, work_exit_ch) = stream::<()>(); let work_exit_ch = SharedChan::new(work_exit_ch); - for iter::repeat(7u) { + for old_iter::repeat(7u) { let iotask_clone = iotask.clone(); let work_exit_ch_clone = work_exit_ch.clone(); do task::spawn_sched(task::ManualThreads(1u)) { @@ -295,7 +295,7 @@ fn test_uv_iotask_async() { work_exit_ch_clone.send(()); }; }; - for iter::repeat(7u) { + for old_iter::repeat(7u) { debug!("waiting"); work_exit_po.recv(); }; diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 88d7c39cc8376..fd1c5a960d149 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -16,8 +16,9 @@ * other useful things like `push()` and `len()`. */ -use core::iter; -use core::iter::BaseIter; +use core::prelude::*; +use core::old_iter; +use core::old_iter::BaseIter; #[auto_encode] #[auto_decode] @@ -116,7 +117,7 @@ impl OptVec { #[inline(always)] fn mapi_to_vec(&self, op: &fn(uint, &T) -> B) -> ~[B] { let mut index = 0; - iter::map_to_vec(self, |a| { + old_iter::map_to_vec(self, |a| { let i = index; index += 1; op(i, a) @@ -154,62 +155,62 @@ impl BaseIter for OptVec { } } -impl iter::ExtendedIter for OptVec { +impl old_iter::ExtendedIter for OptVec { #[inline(always)] fn eachi(&self, blk: &fn(v: uint, v: &A) -> bool) { - iter::eachi(self, blk) + old_iter::eachi(self, blk) } #[inline(always)] fn all(&self, blk: &fn(&A) -> bool) -> bool { - iter::all(self, blk) + old_iter::all(self, blk) } #[inline(always)] fn any(&self, blk: &fn(&A) -> bool) -> bool { - iter::any(self, blk) + old_iter::any(self, blk) } #[inline(always)] fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { - iter::foldl(self, b0, blk) + old_iter::foldl(self, b0, blk) } #[inline(always)] fn position(&self, f: &fn(&A) -> bool) -> Option { - iter::position(self, f) + old_iter::position(self, f) } #[inline(always)] fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { - iter::map_to_vec(self, op) + old_iter::map_to_vec(self, op) } #[inline(always)] fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { - iter::flat_map_to_vec(self, op) + old_iter::flat_map_to_vec(self, op) } } -impl iter::EqIter for OptVec { +impl old_iter::EqIter for OptVec { #[inline(always)] - fn contains(&self, x: &A) -> bool { iter::contains(self, x) } + fn contains(&self, x: &A) -> bool { old_iter::contains(self, x) } #[inline(always)] - fn count(&self, x: &A) -> uint { iter::count(self, x) } + fn count(&self, x: &A) -> uint { old_iter::count(self, x) } } -impl iter::CopyableIter for OptVec { +impl old_iter::CopyableIter for OptVec { #[inline(always)] fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { - iter::filter_to_vec(self, pred) + old_iter::filter_to_vec(self, pred) } #[inline(always)] - fn to_vec(&self) -> ~[A] { iter::to_vec(self) } + fn to_vec(&self) -> ~[A] { old_iter::to_vec(self) } #[inline(always)] fn find(&self, f: &fn(&A) -> bool) -> Option { - iter::find(self, f) + old_iter::find(self, f) } } -impl iter::CopyableOrderedIter for OptVec { +impl old_iter::CopyableOrderedIter for OptVec { #[inline(always)] - fn min(&self) -> A { iter::min(self) } + fn min(&self) -> A { old_iter::min(self) } #[inline(always)] - fn max(&self) -> A { iter::max(self) } + fn max(&self) -> A { old_iter::max(self) } } diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index c29ab9a769e1a..2588916705045 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -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) diff --git a/src/test/run-fail/extern-fail.rs b/src/test/run-fail/extern-fail.rs index ca8c6e8246fdb..2deee10527cc9 100644 --- a/src/test/run-fail/extern-fail.rs +++ b/src/test/run-fail/extern-fail.rs @@ -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); diff --git a/src/test/run-pass/bitv-perf-test.rs b/src/test/run-pass/bitv-perf-test.rs index 6cb0cf4e3776d..bf2285480b477 100644 --- a/src/test/run-pass/bitv-perf-test.rs +++ b/src/test/run-pass/bitv-perf-test.rs @@ -21,5 +21,5 @@ fn bitv_test() -> bool { } pub fn main() { - do iter::repeat(10000) || {bitv_test()}; + do old_iter::repeat(10000) || {bitv_test()}; } diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index e4374e4d225a7..cf887758bff7d 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -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 } diff --git a/src/test/run-pass/class-trait-bounded-param.rs b/src/test/run-pass/class-trait-bounded-param.rs index f4fd548a8e44f..e1929d33d5b9c 100644 --- a/src/test/run-pass/class-trait-bounded-param.rs +++ b/src/test/run-pass/class-trait-bounded-param.rs @@ -14,7 +14,7 @@ extern mod std; use std::oldmap::{map, hashmap, int_hash}; class keys> - : iter::base_iter { + : old_iter::base_iter { let map: M; @@ -24,12 +24,12 @@ class keys> fn each(blk: &fn(K) -> bool) { self.map.each(|k, _v| blk(k) ) } fn size_hint() -> Option { 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]); } diff --git a/src/test/run-pass/early-vtbl-resolution.rs b/src/test/run-pass/early-vtbl-resolution.rs index 4728f71846357..58b192e839b38 100644 --- a/src/test/run-pass/early-vtbl-resolution.rs +++ b/src/test/run-pass/early-vtbl-resolution.rs @@ -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); } diff --git a/src/test/run-pass/extern-stress.rs b/src/test/run-pass/extern-stress.rs index e334dabe88365..0b640c8c62360 100644 --- a/src/test/run-pass/extern-stress.rs +++ b/src/test/run-pass/extern-stress.rs @@ -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); }; diff --git a/src/test/run-pass/extern-yield.rs b/src/test/run-pass/extern-yield.rs index 13c3fd44f3969..bde3f5dd52ff6 100644 --- a/src/test/run-pass/extern-yield.rs +++ b/src/test/run-pass/extern-yield.rs @@ -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); diff --git a/src/test/run-pass/issue-2611.rs b/src/test/run-pass/issue-2611.rs index af3e8e9c7a2b5..f24605339ad77 100644 --- a/src/test/run-pass/issue-2611.rs +++ b/src/test/run-pass/issue-2611.rs @@ -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 { fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B]; @@ -16,7 +16,7 @@ trait FlatMapToVec { impl FlatMapToVec for ~[A] { fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { - iter::flat_map_to_vec(self, op) + old_iter::flat_map_to_vec(self, op) } } diff --git a/src/test/run-pass/iter-all.rs b/src/test/run-pass/iter-all.rs index 1e81c72148f73..b21ddc656c93c 100644 --- a/src/test/run-pass/iter-all.rs +++ b/src/test/run-pass/iter-all.rs @@ -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::, is_even)); + assert!(!old_iter::all(&Some(1u), is_even)); + assert!(old_iter::all(&Some(2u), is_even)); + assert!(old_iter::all(&None::, is_even)); } diff --git a/src/test/run-pass/iter-any.rs b/src/test/run-pass/iter-any.rs index 6f3114f1290bc..657c8d7c62459 100644 --- a/src/test/run-pass/iter-any.rs +++ b/src/test/run-pass/iter-any.rs @@ -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::, is_even)); + assert!(!old_iter::any(&Some(1u), is_even)); + assert!(old_iter::any(&Some(2u), is_even)); + assert!(!old_iter::any(&None::, is_even)); } diff --git a/src/test/run-pass/iter-contains.rs b/src/test/run-pass/iter-contains.rs index 7b8beda9bf107..fe10ecdcf95e4 100644 --- a/src/test/run-pass/iter-contains.rs +++ b/src/test/run-pass/iter-contains.rs @@ -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::, &22u) == false); - assert!(iter::contains(&Some(1u), &22u) == false); - assert!(iter::contains(&Some(22u), &22u) == true); + assert!(old_iter::contains(&None::, &22u) == false); + assert!(old_iter::contains(&Some(1u), &22u) == false); + assert!(old_iter::contains(&Some(22u), &22u) == true); } diff --git a/src/test/run-pass/iter-count.rs b/src/test/run-pass/iter-count.rs index 8f67e48948610..8e061775c2bfa 100644 --- a/src/test/run-pass/iter-count.rs +++ b/src/test/run-pass/iter-count.rs @@ -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::, &22u) == 0u); - assert!(iter::count(&Some(1u), &22u) == 0u); - assert!(iter::count(&Some(22u), &22u) == 1u); + assert!(old_iter::count(&None::, &22u) == 0u); + assert!(old_iter::count(&Some(1u), &22u) == 0u); + assert!(old_iter::count(&Some(22u), &22u) == 1u); } diff --git a/src/test/run-pass/iter-eachi.rs b/src/test/run-pass/iter-eachi.rs index cbf4243c4096f..03130a6632c3c 100644 --- a/src/test/run-pass/iter-eachi.rs +++ b/src/test/run-pass/iter-eachi.rs @@ -16,10 +16,10 @@ pub fn main() { } assert!(c == 5u); - for iter::eachi(&None::) |i, v| { fail!(); } + for old_iter::eachi(&None::) |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; } diff --git a/src/test/run-pass/iter-filter-to-vec.rs b/src/test/run-pass/iter-filter-to-vec.rs index 4fd523ea2c0ea..a9cdec9a0b7cc 100644 --- a/src/test/run-pass/iter-filter-to-vec.rs +++ b/src/test/run-pass/iter-filter-to-vec.rs @@ -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::, 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::, is_even) == ~[]); + assert!(old_iter::filter_to_vec(&Some(1u), is_even) == ~[]); + assert!(old_iter::filter_to_vec(&Some(2u), is_even) == ~[2]); } diff --git a/src/test/run-pass/iter-flat-map-to-vec.rs b/src/test/run-pass/iter-flat-map-to-vec.rs index b392b8efd2111..d9a7791527e44 100644 --- a/src/test/run-pass/iter-flat-map-to-vec.rs +++ b/src/test/run-pass/iter-flat-map-to-vec.rs @@ -17,13 +17,13 @@ fn incd_if_even(x: &uint) -> Option { 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::, 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::, 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::, 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::, 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]); } diff --git a/src/test/run-pass/iter-foldl.rs b/src/test/run-pass/iter-foldl.rs index e5e5cd44032a7..b299cf8322505 100644 --- a/src/test/run-pass/iter-foldl.rs +++ b/src/test/run-pass/iter-foldl.rs @@ -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::, 20f, add) == 20f); - assert!(iter::foldl(&Some(1u), 20f, add) == 21f); - assert!(iter::foldl(&Some(2u), 20f, add) == 22f); + assert!(old_iter::foldl(&None::, 20f, add) == 20f); + assert!(old_iter::foldl(&Some(1u), 20f, add) == 21f); + assert!(old_iter::foldl(&Some(2u), 20f, add) == 22f); } diff --git a/src/test/run-pass/iter-map-to-vec.rs b/src/test/run-pass/iter-map-to-vec.rs index 17af47d87333a..4e9976e4eb9d3 100644 --- a/src/test/run-pass/iter-map-to-vec.rs +++ b/src/test/run-pass/iter-map-to-vec.rs @@ -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::, 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::, inc) == ~[]); + assert!(old_iter::map_to_vec(&Some(1u), inc) == ~[2]); + assert!(old_iter::map_to_vec(&Some(2u), inc) == ~[3]); } diff --git a/src/test/run-pass/iter-min-max.rs b/src/test/run-pass/iter-min-max.rs index a7160615dbdc2..a8831a9c5ad59 100644 --- a/src/test/run-pass/iter-min-max.rs +++ b/src/test/run-pass/iter-min-max.rs @@ -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); } diff --git a/src/test/run-pass/iter-to-vec.rs b/src/test/run-pass/iter-to-vec.rs index 944e9f5b0a586..d7fdcdbe4e0a0 100644 --- a/src/test/run-pass/iter-to-vec.rs +++ b/src/test/run-pass/iter-to-vec.rs @@ -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::) == ~[]); - assert!(iter::to_vec(&Some(1u)) == ~[1u]); - assert!(iter::to_vec(&Some(2u)) == ~[2u]); + assert!(old_iter::to_vec(&None::) == ~[]); + assert!(old_iter::to_vec(&Some(1u)) == ~[1u]); + assert!(old_iter::to_vec(&Some(2u)) == ~[2u]); }