rename iter2 to each2, make it follow iterator protocol

This commit is contained in:
Niko Matsakis
2012-09-28 15:48:25 -07:00
parent fd8e7aab71
commit 565b39b302
12 changed files with 28 additions and 23 deletions

View File

@@ -524,7 +524,7 @@ impl check_loan_ctxt {
let arg_tys =
ty::ty_fn_args(
ty::node_id_to_type(self.tcx(), callee_id));
do vec::iter2(args, arg_tys) |arg, arg_ty| {
for vec::each2(args, arg_tys) |arg, arg_ty| {
match ty::resolved_mode(self.tcx(), arg_ty.mode) {
ast::by_move => {
self.check_move_out(*arg);

View File

@@ -113,7 +113,7 @@ fn req_loans_in_expr(ex: @ast::expr,
ast::expr_call(f, args, _) => {
let arg_tys = ty::ty_fn_args(ty::expr_ty(self.tcx(), f));
let scope_r = ty::re_scope(ex.id);
do vec::iter2(args, arg_tys) |arg, arg_ty| {
for vec::each2(args, arg_tys) |arg, arg_ty| {
match ty::resolved_mode(self.tcx(), arg_ty.mode) {
ast::by_mutbl_ref => {
let arg_cmt = self.bccx.cat_expr(*arg);

View File

@@ -272,7 +272,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
tys_to_str(cx.tcx, *ts), ts.len(),
*bounds, (*bounds).len());
}
do vec::iter2(*ts, *bounds) |ty, bound| {
for vec::each2(*ts, *bounds) |ty, bound| {
check_bounds(cx, id_to_use, e.span, *ty, *bound)
}
}
@@ -376,7 +376,7 @@ fn check_ty(aty: @ty, cx: ctx, v: visit::vt<ctx>) {
do option::iter(&cx.tcx.node_type_substs.find(id)) |ts| {
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(id));
let bounds = ty::lookup_item_type(cx.tcx, did).bounds;
do vec::iter2(*ts, *bounds) |ty, bound| {
for vec::each2(*ts, *bounds) |ty, bound| {
check_bounds(cx, aty.id, aty.span, *ty, *bound)
}
}

View File

@@ -675,7 +675,7 @@ fn check_fn_deprecated_modes(tcx: ty::ctxt, fn_ty: ty::t, decl: ast::fn_decl,
match ty::get(fn_ty).sty {
ty::ty_fn(fn_ty) => {
let mut counter = 0;
do vec::iter2(fn_ty.sig.inputs, decl.inputs) |arg_ty, arg_ast| {
for vec::each2(fn_ty.sig.inputs, decl.inputs) |arg_ty, arg_ast| {
counter += 1;
debug!("arg %d, ty=%s, mode=%s",
counter,

View File

@@ -1571,7 +1571,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
expr_call(f, args, _) => {
let targs = ty::ty_fn_args(ty::expr_ty(self.tcx, f));
do vec::iter2(args, targs) |arg_expr, arg_ty| {
for vec::each2(args, targs) |arg_expr, arg_ty| {
match ty::resolved_mode(self.tcx, arg_ty.mode) {
by_val | by_copy | by_ref | by_mutbl_ref => {}
by_move => {

View File

@@ -49,7 +49,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, 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);
do vec::iter2(*vs_here, *vs_there) |here, there| {
for vec::each2(*vs_here, *vs_there) |here, there| {
if there.id == fn_id { my_id = here.id.node; }
ccx.external.insert(there.id, Some(here.id.node));
}

View File

@@ -204,10 +204,10 @@ fn mark_for_expr(cx: ctx, e: @expr) {
expr_path(_) => {
do cx.ccx.tcx.node_type_substs.find(e.id).iter |ts| {
let id = ast_util::def_id_of_def(cx.ccx.tcx.def_map.get(e.id));
vec::iter2(type_uses_for(cx.ccx, id, ts.len()), *ts,
|uses, subst| {
type_needs(cx, *uses, *subst)
})
let uses_for_ts = type_uses_for(cx.ccx, id, ts.len());
for vec::each2(uses_for_ts, *ts) |uses, subst| {
type_needs(cx, *uses, *subst)
}
}
}
expr_fn(*) | expr_fn_block(*) => {
@@ -238,8 +238,10 @@ fn mark_for_expr(cx: ctx, e: @expr) {
match mth.origin {
typeck::method_static(did) => {
do cx.ccx.tcx.node_type_substs.find(e.id).iter |ts| {
do vec::iter2(type_uses_for(cx.ccx, did, ts.len()), *ts)
|uses, subst| { type_needs(cx, *uses, *subst)}
let type_uses = type_uses_for(cx.ccx, did, ts.len());
for vec::each2(type_uses, *ts) |uses, subst| {
type_needs(cx, *uses, *subst)
}
}
}
typeck::method_param({param_num: param, _}) => {

View File

@@ -308,7 +308,7 @@ fn check_fn(ccx: @crate_ctxt,
for self_info.each |info| {
fcx.write_ty(info.self_id, info.self_ty);
}
do vec::iter2(decl.inputs, arg_tys) |input, arg| {
for vec::each2(decl.inputs, arg_tys) |input, arg| {
fcx.write_ty(input.id, *arg);
}
@@ -351,7 +351,7 @@ fn check_fn(ccx: @crate_ctxt,
}
// Add formal parameters.
do vec::iter2(arg_tys, decl.inputs) |arg_ty, input| {
for vec::each2(arg_tys, decl.inputs) |arg_ty, input| {
assign(input.ty.span, input.id, Some(*arg_ty));
debug!("Argument %s is assigned to %s",
tcx.sess.str_of(input.ident),

View File

@@ -164,7 +164,7 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
}
do subpats.iter() |pats| {
do vec::iter2(*pats, arg_types) |subpat, arg_ty| {
for vec::each2(*pats, arg_types) |subpat, arg_ty| {
check_pat(pcx, *subpat, *arg_ty);
}
};

View File

@@ -392,8 +392,9 @@ fn connect_trait_tps(fcx: @fn_ctxt, expr: @ast::expr, impl_tys: ~[ty::t],
ty::get(trait_ty).sty, impl_did);
match ty::get(trait_ty).sty {
ty::ty_trait(_, substs, _) => {
vec::iter2(substs.tps, trait_tys,
|a, b| demand::suptype(fcx, expr.span, *a, *b));
for vec::each2(substs.tps, trait_tys) |a, b| {
demand::suptype(fcx, expr.span, *a, *b)
}
}
_ => tcx.sess.impossible_case(expr.span, "connect_trait_tps: \
don't know how to handle a non-trait ty")