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
This commit is contained in:
Erick Tryzelaar 2012-05-26 19:15:50 -07:00
parent a5e921dcae
commit 46173e98ef
2 changed files with 14 additions and 10 deletions

View File

@ -142,7 +142,7 @@ checking for overflow:
assert incd == [2u, 3u, 4u];
}
"]
fn map<T,U:copy,V:copy>(
fn map_vec<T,U:copy,V:copy>(
ts: [T], op: fn(T) -> result<V,U>) -> 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<S,T,U:copy,V:copy>(ss: [S], ts: [T], op: fn(S,T) -> result<V,U>)
fn map_vec2<S,T,U:copy,V:copy>(ss: [S], ts: [T], op: fn(S,T) -> result<V,U>)
: vec::same_length(ss, ts) -> result<[V],U> {
let n = vec::len(ts);
@ -199,7 +199,7 @@ 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<S,T,U:copy>(ss: [S], ts: [T],
fn iter_vec2<S,T,U:copy>(ss: [S], ts: [T],
op: fn(S,T) -> result<(),U>)
: vec::same_length(ss, ts)
-> result<(),U> {

View File

@ -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<C:combine>(
// 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<C:combine>(
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<C:combine>(
(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<C:combine>(
(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 {