about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/middle/kind.rs5
-rw-r--r--src/librustc/middle/trans/inline.rs3
-rw-r--r--src/librustc/middle/trans/type_use.rs5
-rw-r--r--src/librustc/middle/typeck/check/_match.rs4
-rw-r--r--src/librustc/middle/typeck/check/mod.rs6
-rw-r--r--src/librustc/middle/typeck/coherence.rs7
-rw-r--r--src/libstd/vec.rs38
-rw-r--r--src/libsyntax/ext/deriving/generic.rs5
-rw-r--r--src/test/bench/shootout-fannkuch-redux.rs6
-rw-r--r--src/test/run-pass/vec-each2_mut.rs42
10 files changed, 24 insertions, 97 deletions
diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs
index 736e98dc6ec..543264ba11e 100644
--- a/src/librustc/middle/kind.rs
+++ b/src/librustc/middle/kind.rs
@@ -17,6 +17,7 @@ use middle::typeck;
 use util::ppaux::{Repr, ty_to_str};
 use util::ppaux::UserString;
 
+use core::iterator::IteratorUtil;
 use core::vec;
 use syntax::ast::*;
 use syntax::attr::attrs_contains_name;
@@ -268,7 +269,7 @@ pub fn check_expr(e: @expr, cx: Context, v: visit::vt<Context>) {
                   ts.repr(cx.tcx),
                   type_param_defs.repr(cx.tcx));
         }
-        for vec::each2(**ts, *type_param_defs) |&ty, type_param_def| {
+        for ts.iter().zip(type_param_defs.iter()).advance |(&ty, type_param_def)| {
             check_bounds(cx, type_parameter_id, e.span, ty, type_param_def)
         }
     }
@@ -309,7 +310,7 @@ fn check_ty(aty: @Ty, cx: Context, v: visit::vt<Context>) {
             let did = ast_util::def_id_of_def(cx.tcx.def_map.get_copy(&id));
             let type_param_defs =
                 ty::lookup_item_type(cx.tcx, did).generics.type_param_defs;
-            for vec::each2(**ts, *type_param_defs) |&ty, type_param_def| {
+            for ts.iter().zip(type_param_defs.iter()).advance |(&ty, type_param_def)| {
                 check_bounds(cx, aty.id, aty.span, ty, type_param_def)
             }
         }
diff --git a/src/librustc/middle/trans/inline.rs b/src/librustc/middle/trans/inline.rs
index 1f9bdcb5abb..88f97cfa0b8 100644
--- a/src/librustc/middle/trans/inline.rs
+++ b/src/librustc/middle/trans/inline.rs
@@ -19,6 +19,7 @@ use middle::trans::common::*;
 use middle::ty;
 use util::ppaux::ty_to_str;
 
+use core::iterator::IteratorUtil;
 use core::vec;
 use syntax::ast;
 use syntax::ast_map::path_name;
@@ -75,7 +76,7 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::def_id,
             ast::item_enum(_, _) => {
               let vs_here = ty::enum_variants(ccx.tcx, local_def(item.id));
               let vs_there = ty::enum_variants(ccx.tcx, parent_id);
-              for vec::each2(*vs_here, *vs_there) |here, there| {
+              for vs_here.iter().zip(vs_there.iter()).advance |(here, there)| {
                   if there.id == fn_id { my_id = here.id.node; }
                   ccx.external.insert(there.id, Some(here.id.node));
               }
diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs
index 9c84b4ffa99..b1b1b5212af 100644
--- a/src/librustc/middle/trans/type_use.rs
+++ b/src/librustc/middle/trans/type_use.rs
@@ -33,6 +33,7 @@ use middle::trans::inline;
 use middle::ty;
 use middle::typeck;
 
+use core::iterator::IteratorUtil;
 use core::option::{Some, None};
 use core::uint;
 use core::vec;
@@ -264,7 +265,7 @@ pub fn mark_for_method_call(cx: Context, e_id: node_id, callee_id: node_id) {
     for opt_static_did.each |&did| {
         for cx.ccx.tcx.node_type_substs.find_copy(&callee_id).each |ts| {
             let type_uses = type_uses_for(cx.ccx, did, ts.len());
-            for vec::each2(*type_uses, *ts) |uses, subst| {
+            for type_uses.iter().zip(ts.iter()).advance |(uses, subst)| {
                 type_needs(cx, *uses, *subst)
             }
         }
@@ -302,7 +303,7 @@ pub fn mark_for_expr(cx: Context, e: @expr) {
         for opt_ts.each |ts| {
             let id = ast_util::def_id_of_def(cx.ccx.tcx.def_map.get_copy(&e.id));
             let uses_for_ts = type_uses_for(cx.ccx, id, ts.len());
-            for vec::each2(*uses_for_ts, *ts) |uses, subst| {
+            for uses_for_ts.iter().zip(ts.iter()).advance |(uses, subst)| {
                 type_needs(cx, *uses, *subst)
             }
         }
diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs
index 03803a64fc3..13f41c06e18 100644
--- a/src/librustc/middle/typeck/check/_match.rs
+++ b/src/librustc/middle/typeck/check/_match.rs
@@ -18,8 +18,8 @@ use middle::typeck::check::{instantiate_path, lookup_def};
 use middle::typeck::check::{structure_of, valid_range_bounds};
 use middle::typeck::require_same_types;
 
+use core::iterator::IteratorUtil;
 use core::hashmap::{HashMap, HashSet};
-use core::vec;
 use syntax::ast;
 use syntax::ast_util;
 use syntax::codemap::span;
@@ -232,7 +232,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
 
         if !error_happened {
             for subpats.each |pats| {
-                for vec::each2(*pats, arg_types) |subpat, arg_ty| {
+                for pats.iter().zip(arg_types.iter()).advance |(subpat, arg_ty)| {
                     check_pat(pcx, *subpat, *arg_ty);
                 }
             }
diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs
index c69aeeb4aa8..1e5f8970448 100644
--- a/src/librustc/middle/typeck/check/mod.rs
+++ b/src/librustc/middle/typeck/check/mod.rs
@@ -110,6 +110,8 @@ use util::common::{block_query, indenter, loop_query};
 use util::ppaux::{bound_region_to_str};
 use util::ppaux;
 
+
+use core::iterator::IteratorUtil;
 use core::cast::transmute;
 use core::hashmap::HashMap;
 use core::result;
@@ -412,7 +414,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
     for opt_self_info.each |self_info| {
         fcx.write_ty(self_info.self_id, self_info.self_ty);
     }
-    for vec::each2(decl.inputs, arg_tys) |input, arg| {
+    for decl.inputs.iter().zip(arg_tys.iter()).advance |(input, arg)| {
         fcx.write_ty(input.id, *arg);
     }
 
@@ -449,7 +451,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
         }
 
         // Add formal parameters.
-        for vec::each2(arg_tys, decl.inputs) |arg_ty, input| {
+        for arg_tys.iter().zip(decl.inputs.iter()).advance |(arg_ty, input)| {
             // Create type variables for each argument.
             do pat_util::pat_bindings(tcx.def_map, input.pat)
                     |_bm, pat_id, _sp, _path| {
diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs
index 9d25430d80b..dcf165b0496 100644
--- a/src/librustc/middle/typeck/coherence.rs
+++ b/src/librustc/middle/typeck/coherence.rs
@@ -54,6 +54,7 @@ use syntax::visit::{Visitor, SimpleVisitor};
 use syntax::visit::{visit_mod};
 use util::ppaux::ty_to_str;
 
+use core::iterator::IteratorUtil;
 use core::hashmap::{HashMap, HashSet};
 use core::old_iter;
 use core::result::Ok;
@@ -617,9 +618,9 @@ impl CoherenceChecker {
                 // Check to ensure that each parameter binding respected its
                 // kind bounds.
                 for [ a, b ].each |result| {
-                    for vec::each2(result.type_variables,
-                                   *result.type_param_defs)
-                        |ty_var, type_param_def|
+                    for result.type_variables.iter()
+                        .zip(result.type_param_defs.iter())
+                        .advance |(ty_var, type_param_def)|
                     {
                         if type_param_def.bounds.builtin_bounds.contains_elem(
                             ty::BoundCopy)
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index 8340b956b65..54efd35b91e 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -1667,44 +1667,6 @@ pub fn eachi_reverse<'r,T>(v: &'r [T],
 }
 
 /**
- * Iterates over two vectors simultaneously
- *
- * # Failure
- *
- * Both vectors must have the same length
- */
-#[inline]
-pub fn each2<U, T>(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) -> bool {
-    assert_eq!(v1.len(), v2.len());
-    for uint::range(0u, v1.len()) |i| {
-        if !f(&v1[i], &v2[i]) {
-            return false;
-        }
-    }
-    return true;
-}
-
-/**
- *
- * Iterates over two vector with mutable.
- *
- * # Failure
- *
- * Both vectors must have the same length
- */
-#[inline]
-pub fn each2_mut<U, T>(v1: &mut [U], v2: &mut [T],
-                       f: &fn(u: &mut U, t: &mut T) -> bool) -> bool {
-    assert_eq!(v1.len(), v2.len());
-    for uint::range(0u, v1.len()) |i| {
-        if !f(&mut v1[i], &mut v2[i]) {
-            return false;
-        }
-    }
-    return true;
-}
-
-/**
  * Iterate over all permutations of vector `v`.
  *
  * Permutations are produced in lexicographic order with respect to the order
diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs
index 52a2d9ff9de..b36d4496492 100644
--- a/src/libsyntax/ext/deriving/generic.rs
+++ b/src/libsyntax/ext/deriving/generic.rs
@@ -174,6 +174,7 @@ use opt_vec;
 
 use core::uint;
 use core::vec;
+use core::iterator::IteratorUtil;
 
 pub use self::ty::*;
 mod ty;
@@ -616,7 +617,7 @@ impl<'self> MethodDef<'self> {
         // make a series of nested matches, to destructure the
         // structs. This is actually right-to-left, but it shoudn't
         // matter.
-        for vec::each2(self_args, patterns) |&arg_expr, &pat| {
+        for self_args.iter().zip(patterns.iter()).advance |(&arg_expr, &pat)| {
             body = cx.expr_match(span, arg_expr,
                                  ~[ cx.arm(span, ~[pat], body) ])
         }
@@ -951,7 +952,7 @@ fn create_struct_pattern(cx: @ExtCtxt,
     // must be nonempty to reach here
     let pattern = if struct_type == Record {
         let field_pats = do vec::build |push| {
-            for vec::each2(subpats, ident_expr) |&pat, &(id, _)| {
+            for subpats.iter().zip(ident_expr.iter()).advance |(&pat, &(id, _))| {
                 // id is guaranteed to be Some
                 push(ast::field_pat { ident: id.get(), pat: pat })
             }
diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs
index b1db5843b7c..4dd4d2b5847 100644
--- a/src/test/bench/shootout-fannkuch-redux.rs
+++ b/src/test/bench/shootout-fannkuch-redux.rs
@@ -1,3 +1,4 @@
+use std::iterator::*;
 use std::from_str::FromStr;
 use std::i32::range;
 use std::os;
@@ -29,9 +30,8 @@ fn fannkuch_redux(n: i32) -> i32 {
                 r -= 1;
             }
 
-            // XXX: Need each2_mut.
-            for vec::eachi_mut(perm) |i, perm_i| {
-                *perm_i = perm1.unsafe_get(i);
+            for perm.mut_iter().zip(perm1.iter()).advance |(perm_i, perm1_i)| {
+                *perm_i = *perm1_i;
             }
 
             let mut flips_count: i32 = 0;
diff --git a/src/test/run-pass/vec-each2_mut.rs b/src/test/run-pass/vec-each2_mut.rs
deleted file mode 100644
index 73e0418993c..00000000000
--- a/src/test/run-pass/vec-each2_mut.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2012 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.
-
-// -*- rust -*-
-
-use std::io;
-use std::vec;
-
-fn main(){
-    let mut t1 = ~[];
-    t1.push('a');
-
-    let mut t2 = ~[];
-    t2.push('b');
-
-    for vec::each2_mut(t1, t2) | i1, i2 | {
-        assert_eq!(*i1, 'a');
-        assert_eq!(*i2, 'b');
-    }
-
-    for vec::each2(t1, t2) | i1, i2 | {
-        io::println(fmt!("after t1: %?, t2: %?", i1, i2));
-    }
-
-    for vec::each2_mut(t1, t2) | i1, i2 | {
-        *i1 = 'b';
-        *i2 = 'a';
-        assert_eq!(*i1, 'b');
-        assert_eq!(*i2, 'a');
-    }
-
-    for vec::each2(t1, t2) | i1, i2 | {
-        io::println(fmt!("before t1: %?, t2: %?", i1, i2));
-    }
-}