From 46173e98ef03690406d08ec9abad50d80e127e69 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Sat, 26 May 2012 19:15:50 -0700 Subject: [PATCH] Rename result::{iter,map,map2} to add _vec suffix The result module doesn't follow the standard iter/map pattern that we use in the rest of the library. So to --- src/libcore/result.rs | 8 ++++---- src/rustc/middle/typeck/infer.rs | 16 ++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 18d78520bf5..b0fad3192be 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -142,7 +142,7 @@ checking for overflow: assert incd == [2u, 3u, 4u]; } "] -fn map( +fn map_vec( ts: [T], op: fn(T) -> result) -> result<[V],U> { let mut vs: [V] = []; @@ -177,7 +177,7 @@ length. While we do not often use preconditions in the standard library, a precondition is used here because result::t is generally used in 'careful' code contexts where it is both appropriate and easy to accommodate an error like the vectors being of different lengths."] -fn map2(ss: [S], ts: [T], op: fn(S,T) -> result) +fn map_vec2(ss: [S], ts: [T], op: fn(S,T) -> result) : vec::same_length(ss, ts) -> result<[V],U> { let n = vec::len(ts); @@ -199,8 +199,8 @@ Applies op to the pairwise elements from `ss` and `ts`, aborting on error. This could be implemented using `map2()` but it is more efficient on its own as no result vector is built. "] -fn iter2(ss: [S], ts: [T], - op: fn(S,T) -> result<(),U>) +fn iter_vec2(ss: [S], ts: [T], + op: fn(S,T) -> result<(),U>) : vec::same_length(ss, ts) -> result<(),U> { diff --git a/src/rustc/middle/typeck/infer.rs b/src/rustc/middle/typeck/infer.rs index 02349614e55..1f4d479671c 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -151,7 +151,7 @@ import middle::ty::{ty_vid, tys_in_fn_ty, region_vid, vid}; import syntax::{ast, ast_util}; import syntax::ast::{ret_style}; import util::ppaux::{ty_to_str, mt_to_str}; -import result::{result, extensions, ok, err, map, map2, iter2}; +import result::{result, extensions, ok, err, map_vec, map_vec2, iter_vec2}; import ty::{mk_fn, type_is_bot}; import check::regionmanip::{collect_bound_regions_in_tys, replace_bound_regions}; @@ -753,7 +753,7 @@ impl unify_methods for infer_ctxt { as: [@ty::type_constr], bs: [@ty::type_constr]) -> ures { if check vec::same_length(as, bs) { - iter2(as, bs) {|a,b| + iter_vec2(as, bs) {|a,b| self.constrs(a, b) } } else { @@ -1237,7 +1237,9 @@ fn super_tps( // variance. if check vec::same_length(as, bs) { - iter2(as, bs) {|a, b| self.infcx().eq_tys(a, b) }.then {|| + iter_vec2(as, bs) {|a, b| + self.infcx().eq_tys(a, b) + }.then {|| ok(as) } } else { @@ -1331,7 +1333,7 @@ fn super_fns( self: C, a_args: [ty::arg], b_args: [ty::arg]) -> cres<[ty::arg]> { if check vec::same_length(a_args, b_args) { - map2(a_args, b_args) {|a, b| self.args(a, b) } + map_vec2(a_args, b_args) {|a, b| self.args(a, b) } } else { err(ty::terr_arg_count) } @@ -1469,7 +1471,9 @@ fn super_tys( (ty::ty_rec(as), ty::ty_rec(bs)) { if check vec::same_length(as, bs) { - map2(as, bs) {|a,b| self.flds(a, b) }.chain {|flds| + map_vec2(as, bs) {|a,b| + self.flds(a, b) + }.chain {|flds| ok(ty::mk_rec(tcx, flds)) } } else { @@ -1479,7 +1483,7 @@ fn super_tys( (ty::ty_tup(as), ty::ty_tup(bs)) { if check vec::same_length(as, bs) { - map2(as, bs) {|a, b| self.tys(a, b) }.chain {|ts| + map_vec2(as, bs) {|a, b| self.tys(a, b) }.chain {|ts| ok(ty::mk_tup(tcx, ts)) } } else {