about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-04-24 20:35:49 -0400
committerDaniel Micay <danielmicay@gmail.com>2013-04-28 22:31:39 -0400
commit46f91a0fa95cd13f7433a1d72d087283f483a4b8 (patch)
treec4d6aedddc64db81f6ada877e9ec585cf981d2d9 /src/libcore
parent9f03d45c56b37b36912c16bd5b4fb4723fd91cb7 (diff)
downloadrust-46f91a0fa95cd13f7433a1d72d087283f483a4b8.tar.gz
rust-46f91a0fa95cd13f7433a1d72d087283f483a4b8.zip
make way for a new iter module
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/at_vec.rs4
-rw-r--r--src/libcore/core.rc8
-rw-r--r--src/libcore/hashmap.rs8
-rw-r--r--src/libcore/iter.rs401
-rw-r--r--src/libcore/num/uint-template/uint.rs2
-rw-r--r--src/libcore/old_iter.rs346
-rw-r--r--src/libcore/option.rs18
-rw-r--r--src/libcore/prelude.rs8
-rw-r--r--src/libcore/task/mod.rs18
-rw-r--r--src/libcore/vec.rs150
10 files changed, 534 insertions, 429 deletions
diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs
index e2bce1bd0f0..6ce1acf5947 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<T, U>(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<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
+pub fn from_fn<T>(n_elts: uint, op: old_iter::InitOp<T>) -> @[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 158da9a12fc..dc3cd03dc20 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 d2be0416371..41f4f34dc19 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<T:Hash + Eq> Set<T> for HashSet<T> {
     /// 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<T>) -> 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<T>) -> 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 3dcca0e06c2..7476531ef94 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<A> {
-    fn each(&self, blk: &fn(v: &A) -> bool);
-    fn size_hint(&self) -> Option<uint>;
-}
+~~~~
+use core::iter::iter_to_vec;
+println(iter_to_vec(|f| uint::range(0, 20, f)).to_str());
+~~~~
 
-pub trait ReverseIter<A>: BaseIter<A> {
-    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<A>: BaseIter<A> {
-    fn each_mut(&mut self, blk: &fn(&mut A) -> bool);
-}
+~~~~
+use core::iterator::*;
 
-pub trait ExtendedIter<A> {
-    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<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B;
-    fn position(&self, f: &fn(&A) -> bool) -> Option<uint>;
-    fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B];
-    fn flat_map_to_vec<B,IB: BaseIter<B>>(&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<A> {
-    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<A:Eq> {
-    fn contains(&self, x: &A) -> bool;
-    fn count(&self, x: &A) -> uint;
-}
+*/
 
 pub trait Times {
     fn times(&self, it: &fn() -> bool);
 }
 
-pub trait CopyableIter<A:Copy> {
-    fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A];
-    fn to_vec(&self) -> ~[A];
-    fn find(&self, p: &fn(&A) -> bool) -> Option<A>;
-}
-
-pub trait CopyableOrderedIter<A:Copy + Ord> {
-    fn min(&self) -> A;
-    fn max(&self) -> A;
-}
-
-pub trait CopyableNonstrictIter<A:Copy> {
-    // 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<A> {
-    /**
-     * 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<A,IA:BaseIter<A>>(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<A,IA:BaseIter<A>>(self: &IA, blk: &fn(&A) -> bool) -> bool {
-    for self.each |a| {
-        if !blk(a) { return false; }
-    }
-    return true;
-}
-
-#[inline(always)]
-pub fn any<A,IA:BaseIter<A>>(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<A:Copy,IA:BaseIter<A>>(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<A,B,IA:BaseIter<A>>(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<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(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<A,B,IA:BaseIter<A>>(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<A:Copy,IA:BaseIter<A>>(self: &IA) -> ~[A] {
-    map_to_vec(self, |&x| x)
-}
-
-#[inline(always)]
-pub fn contains<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> bool {
-    for self.each |a| {
-        if *a == *x { return true; }
-    }
-    return false;
-}
-
-#[inline(always)]
-pub fn count<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> uint {
-    do foldl(self, 0) |count, value| {
-        if *value == *x {
-            *count + 1
-        } else {
-            *count
-        }
-    }
-}
-
-#[inline(always)]
-pub fn position<A,IA:BaseIter<A>>(self: &IA, f: &fn(&A) -> bool)
-                               -> Option<uint> {
-    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<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
-    match do foldl::<A,Option<A>,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<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
-    match do foldl::<A,Option<A>,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<A:Copy,IA:BaseIter<A>>(self: &IA, f: &fn(&A) -> bool)
-                                -> Option<A> {
-    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<A,B: Buildable<A>>(builder: &fn(push: &fn(A))) -> B {
-    Buildable::build_sized(4, builder)
+pub fn iter_to_vec<T>(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<A,B: Buildable<A>>(size: Option<uint>,
-                                          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<T,IT: BaseIter<T>,U,BU: Buildable<U>>(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<T>(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<T,BT: Buildable<T>>(n_elts: uint, op: InitOp<T>) -> 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<T:Copy,BT:Buildable<T>>(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<T>(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<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(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<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(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<T>(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 6a8567451e6..de882f1ee7a 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 00000000000..98b847c75b4
--- /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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<A> {
+    fn each(&self, blk: &fn(v: &A) -> bool);
+    fn size_hint(&self) -> Option<uint>;
+}
+
+pub trait ReverseIter<A>: BaseIter<A> {
+    fn each_reverse(&self, blk: &fn(&A) -> bool);
+}
+
+pub trait MutableIter<A>: BaseIter<A> {
+    fn each_mut(&mut self, blk: &fn(&mut A) -> bool);
+}
+
+pub trait ExtendedIter<A> {
+    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<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B;
+    fn position(&self, f: &fn(&A) -> bool) -> Option<uint>;
+    fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B];
+    fn flat_map_to_vec<B,IB: BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B];
+}
+
+pub trait ExtendedMutableIter<A> {
+    fn eachi_mut(&mut self, blk: &fn(uint, &mut A) -> bool);
+}
+
+pub trait EqIter<A:Eq> {
+    fn contains(&self, x: &A) -> bool;
+    fn count(&self, x: &A) -> uint;
+}
+
+pub trait CopyableIter<A:Copy> {
+    fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A];
+    fn to_vec(&self) -> ~[A];
+    fn find(&self, p: &fn(&A) -> bool) -> Option<A>;
+}
+
+pub trait CopyableOrderedIter<A:Copy + Ord> {
+    fn min(&self) -> A;
+    fn max(&self) -> A;
+}
+
+pub trait CopyableNonstrictIter<A:Copy> {
+    // 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<A> {
+    /**
+     * 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<A,IA:BaseIter<A>>(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<A,IA:BaseIter<A>>(self: &IA, blk: &fn(&A) -> bool) -> bool {
+    for self.each |a| {
+        if !blk(a) { return false; }
+    }
+    return true;
+}
+
+#[inline(always)]
+pub fn any<A,IA:BaseIter<A>>(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<A:Copy,IA:BaseIter<A>>(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<A,B,IA:BaseIter<A>>(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<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(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<A,B,IA:BaseIter<A>>(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<A:Copy,IA:BaseIter<A>>(self: &IA) -> ~[A] {
+    map_to_vec(self, |&x| x)
+}
+
+#[inline(always)]
+pub fn contains<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> bool {
+    for self.each |a| {
+        if *a == *x { return true; }
+    }
+    return false;
+}
+
+#[inline(always)]
+pub fn count<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> uint {
+    do foldl(self, 0) |count, value| {
+        if *value == *x {
+            *count + 1
+        } else {
+            *count
+        }
+    }
+}
+
+#[inline(always)]
+pub fn position<A,IA:BaseIter<A>>(self: &IA, f: &fn(&A) -> bool)
+                               -> Option<uint> {
+    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<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
+    match do foldl::<A,Option<A>,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<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
+    match do foldl::<A,Option<A>,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<A:Copy,IA:BaseIter<A>>(self: &IA, f: &fn(&A) -> bool)
+                                -> Option<A> {
+    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<A,B: Buildable<A>>(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<A,B: Buildable<A>>(size: Option<uint>,
+                                          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<T,IT: BaseIter<T>,U,BU: Buildable<U>>(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<T,BT: Buildable<T>>(n_elts: uint, op: InitOp<T>) -> 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<T:Copy,BT:Buildable<T>>(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<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(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<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(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 9b7276879c1..d3519854a0a 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<T> MutableIter<T> for Option<T> {
 
 impl<A> ExtendedIter<A> for Option<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<B>(&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<uint> {
-        iter::position(self, f)
+        old_iter::position(self, f)
     }
     fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] {
-        iter::map_to_vec(self, op)
+        old_iter::map_to_vec(self, op)
     }
     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)
     }
 }
 
diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs
index 7e41f1b5b34..41078fb8920 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 a6c03638713..2163a0e325f 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 176e20f3894..ef42647411a 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<T>(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<T>(n_elts: uint, op: iter::InitOp<T>) -> ~[T] {
+pub fn from_fn<T>(n_elts: uint, op: old_iter::InitOp<T>) -> ~[T] {
     unsafe {
         let mut v = with_capacity(n_elts);
         do as_mut_buf(v) |p, _len| {
@@ -786,7 +786,7 @@ pub fn grow<T:Copy>(v: &mut ~[T], n: uint, initval: &T) {
  * * init_op - A function to call to retreive each appended element's
  *             value
  */
-pub fn grow_fn<T>(v: &mut ~[T], n: uint, op: iter::InitOp<T>) {
+pub fn grow_fn<T>(v: &mut ~[T], n: uint, op: old_iter::InitOp<T>) {
     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<T> {
     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<T>);
+    fn grow_fn(&mut self, n: uint, op: old_iter::InitOp<T>);
 }
 
 impl<T> OwnedVector<T> for ~[T] {
@@ -2344,7 +2344,7 @@ impl<T> OwnedVector<T> for ~[T] {
     }
 
     #[inline]
-    fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>) {
+    fn grow_fn(&mut self, n: uint, op: old_iter::InitOp<T>) {
         grow_fn(self, n, op);
     }
 }
@@ -2643,7 +2643,7 @@ pub mod bytes {
 // ITERATION TRAIT METHODS
 
 #[cfg(stage0)]
-impl<'self,A> iter::BaseIter<A> for &'self [A] {
+impl<'self,A> old_iter::BaseIter<A> 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<A> for &'self [A] {
 #[cfg(stage1)]
 #[cfg(stage2)]
 #[cfg(stage3)]
-impl<'self,A> iter::BaseIter<A> for &'self [A] {
+impl<'self,A> old_iter::BaseIter<A> 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<A> for &'self [A] {
 
 // FIXME(#4148): This should be redundant
 #[cfg(stage0)]
-impl<A> iter::BaseIter<A> for ~[A] {
+impl<A> old_iter::BaseIter<A> for ~[A] {
     #[inline(always)]
     fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) }
     #[inline(always)]
@@ -2673,7 +2673,7 @@ impl<A> iter::BaseIter<A> for ~[A] {
 #[cfg(stage1)]
 #[cfg(stage2)]
 #[cfg(stage3)]
-impl<A> iter::BaseIter<A> for ~[A] {
+impl<A> old_iter::BaseIter<A> 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<A> iter::BaseIter<A> for ~[A] {
 
 // FIXME(#4148): This should be redundant
 #[cfg(stage0)]
-impl<A> iter::BaseIter<A> for @[A] {
+impl<A> old_iter::BaseIter<A> for @[A] {
     #[inline(always)]
     fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) }
     #[inline(always)]
@@ -2693,7 +2693,7 @@ impl<A> iter::BaseIter<A> for @[A] {
 #[cfg(stage1)]
 #[cfg(stage2)]
 #[cfg(stage3)]
-impl<A> iter::BaseIter<A> for @[A] {
+impl<A> old_iter::BaseIter<A> 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<A> iter::BaseIter<A> for @[A] {
 }
 
 #[cfg(stage0)]
-impl<'self,A> iter::MutableIter<A> for &'self mut [A] {
+impl<'self,A> old_iter::MutableIter<A> 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<A> for &'self mut [A] {
 #[cfg(stage1)]
 #[cfg(stage2)]
 #[cfg(stage3)]
-impl<'self,A> iter::MutableIter<A> for &'self mut [A] {
+impl<'self,A> old_iter::MutableIter<A> 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<A> for &'self mut [A] {
 
 // FIXME(#4148): This should be redundant
 #[cfg(stage0)]
-impl<A> iter::MutableIter<A> for ~[A] {
+impl<A> old_iter::MutableIter<A> 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<A> iter::MutableIter<A> for ~[A] {
 #[cfg(stage1)]
 #[cfg(stage2)]
 #[cfg(stage3)]
-impl<A> iter::MutableIter<A> for ~[A] {
+impl<A> old_iter::MutableIter<A> 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<A> iter::MutableIter<A> for ~[A] {
 }
 
 // FIXME(#4148): This should be redundant
-impl<A> iter::MutableIter<A> for @mut [A] {
+impl<A> old_iter::MutableIter<A> 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<A> for &'self [A] {
+impl<'self,A> old_iter::ExtendedIter<A> 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<B>(&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<uint> {
-        iter::position(self, f)
+        old_iter::position(self, f)
     }
     fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] {
-        iter::map_to_vec(self, op)
+        old_iter::map_to_vec(self, op)
     }
     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)
     }
 }
 
-impl<'self,A> iter::ExtendedMutableIter<A> for &'self mut [A] {
+impl<'self,A> old_iter::ExtendedMutableIter<A> 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<A> for &'self mut [A] {
 }
 
 // FIXME(#4148): This should be redundant
-impl<A> iter::ExtendedIter<A> for ~[A] {
+impl<A> old_iter::ExtendedIter<A> 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<B>(&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<uint> {
-        iter::position(self, f)
+        old_iter::position(self, f)
     }
     fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] {
-        iter::map_to_vec(self, op)
+        old_iter::map_to_vec(self, op)
     }
     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)
     }
 }
 
 // FIXME(#4148): This should be redundant
-impl<A> iter::ExtendedIter<A> for @[A] {
+impl<A> old_iter::ExtendedIter<A> 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<B>(&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<uint> {
-        iter::position(self, f)
+        old_iter::position(self, f)
     }
     fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] {
-        iter::map_to_vec(self, op)
+        old_iter::map_to_vec(self, op)
     }
     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)
     }
 }
 
-impl<'self,A:Eq> iter::EqIter<A> 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<A> 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<A:Eq> iter::EqIter<A> 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<A:Eq> old_iter::EqIter<A> 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<A:Eq> iter::EqIter<A> 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<A:Eq> old_iter::EqIter<A> 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<A> for &'self [A] {
+impl<'self,A:Copy> old_iter::CopyableIter<A> 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<A> {
-        iter::find(self, f)
+        old_iter::find(self, f)
     }
 }
 
 // FIXME(#4148): This should be redundant
-impl<A:Copy> iter::CopyableIter<A> for ~[A] {
+impl<A:Copy> old_iter::CopyableIter<A> 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<A> {
-        iter::find(self, f)
+        old_iter::find(self, f)
     }
 }
 
 // FIXME(#4148): This should be redundant
-impl<A:Copy> iter::CopyableIter<A> for @[A] {
+impl<A:Copy> old_iter::CopyableIter<A> 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<A> {
-        iter::find(self, f)
+        old_iter::find(self, f)
     }
 }
 
-impl<'self,A:Copy + Ord> iter::CopyableOrderedIter<A> 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<A> 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<A:Copy + Ord> iter::CopyableOrderedIter<A> for ~[A] {
-    fn min(&self) -> A { iter::min(self) }
-    fn max(&self) -> A { iter::max(self) }
+impl<A:Copy + Ord> old_iter::CopyableOrderedIter<A> 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<A:Copy + Ord> iter::CopyableOrderedIter<A> for @[A] {
-    fn min(&self) -> A { iter::min(self) }
-    fn max(&self) -> A { iter::max(self) }
+impl<A:Copy + Ord> old_iter::CopyableOrderedIter<A> for @[A] {
+    fn min(&self) -> A { old_iter::min(self) }
+    fn max(&self) -> A { old_iter::max(self) }
 }
 
-impl<'self,A:Copy> iter::CopyableNonstrictIter<A> for &'self [A] {
+impl<'self,A:Copy> old_iter::CopyableNonstrictIter<A> 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<A> for &'self [A] {
 }
 
 // FIXME(#4148): This should be redundant
-impl<A:Copy> iter::CopyableNonstrictIter<A> for ~[A] {
+impl<A:Copy> old_iter::CopyableNonstrictIter<A> 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<A:Copy> iter::CopyableNonstrictIter<A> for ~[A] {
 }
 
 // FIXME(#4148): This should be redundant
-impl<A:Copy> iter::CopyableNonstrictIter<A> for @[A] {
+impl<A:Copy> old_iter::CopyableNonstrictIter<A> for @[A] {
     fn each_val(&const self, f: &fn(A) -> bool) {
         let mut i = 0;
         while i < self.len() {