Skip to content

Commit 46173e9

Browse files
committed
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
1 parent a5e921d commit 46173e9

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/libcore/result.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ checking for overflow:
142142
assert incd == [2u, 3u, 4u];
143143
}
144144
"]
145-
fn map<T,U:copy,V:copy>(
145+
fn map_vec<T,U:copy,V:copy>(
146146
ts: [T], op: fn(T) -> result<V,U>) -> result<[V],U> {
147147

148148
let mut vs: [V] = [];
@@ -177,7 +177,7 @@ length. While we do not often use preconditions in the standard
177177
library, a precondition is used here because result::t is generally
178178
used in 'careful' code contexts where it is both appropriate and easy
179179
to accommodate an error like the vectors being of different lengths."]
180-
fn map2<S,T,U:copy,V:copy>(ss: [S], ts: [T], op: fn(S,T) -> result<V,U>)
180+
fn map_vec2<S,T,U:copy,V:copy>(ss: [S], ts: [T], op: fn(S,T) -> result<V,U>)
181181
: vec::same_length(ss, ts) -> result<[V],U> {
182182

183183
let n = vec::len(ts);
@@ -199,8 +199,8 @@ Applies op to the pairwise elements from `ss` and `ts`, aborting on
199199
error. This could be implemented using `map2()` but it is more efficient
200200
on its own as no result vector is built.
201201
"]
202-
fn iter2<S,T,U:copy>(ss: [S], ts: [T],
203-
op: fn(S,T) -> result<(),U>)
202+
fn iter_vec2<S,T,U:copy>(ss: [S], ts: [T],
203+
op: fn(S,T) -> result<(),U>)
204204
: vec::same_length(ss, ts)
205205
-> result<(),U> {
206206

src/rustc/middle/typeck/infer.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ import middle::ty::{ty_vid, tys_in_fn_ty, region_vid, vid};
151151
import syntax::{ast, ast_util};
152152
import syntax::ast::{ret_style};
153153
import util::ppaux::{ty_to_str, mt_to_str};
154-
import result::{result, extensions, ok, err, map, map2, iter2};
154+
import result::{result, extensions, ok, err, map_vec, map_vec2, iter_vec2};
155155
import ty::{mk_fn, type_is_bot};
156156
import check::regionmanip::{collect_bound_regions_in_tys,
157157
replace_bound_regions};
@@ -753,7 +753,7 @@ impl unify_methods for infer_ctxt {
753753
as: [@ty::type_constr], bs: [@ty::type_constr]) -> ures {
754754

755755
if check vec::same_length(as, bs) {
756-
iter2(as, bs) {|a,b|
756+
iter_vec2(as, bs) {|a,b|
757757
self.constrs(a, b)
758758
}
759759
} else {
@@ -1237,7 +1237,9 @@ fn super_tps<C:combine>(
12371237
// variance.
12381238

12391239
if check vec::same_length(as, bs) {
1240-
iter2(as, bs) {|a, b| self.infcx().eq_tys(a, b) }.then {||
1240+
iter_vec2(as, bs) {|a, b|
1241+
self.infcx().eq_tys(a, b)
1242+
}.then {||
12411243
ok(as)
12421244
}
12431245
} else {
@@ -1331,7 +1333,7 @@ fn super_fns<C:combine>(
13311333
self: C, a_args: [ty::arg], b_args: [ty::arg]) -> cres<[ty::arg]> {
13321334

13331335
if check vec::same_length(a_args, b_args) {
1334-
map2(a_args, b_args) {|a, b| self.args(a, b) }
1336+
map_vec2(a_args, b_args) {|a, b| self.args(a, b) }
13351337
} else {
13361338
err(ty::terr_arg_count)
13371339
}
@@ -1469,7 +1471,9 @@ fn super_tys<C:combine>(
14691471

14701472
(ty::ty_rec(as), ty::ty_rec(bs)) {
14711473
if check vec::same_length(as, bs) {
1472-
map2(as, bs) {|a,b| self.flds(a, b) }.chain {|flds|
1474+
map_vec2(as, bs) {|a,b|
1475+
self.flds(a, b)
1476+
}.chain {|flds|
14731477
ok(ty::mk_rec(tcx, flds))
14741478
}
14751479
} else {
@@ -1479,7 +1483,7 @@ fn super_tys<C:combine>(
14791483

14801484
(ty::ty_tup(as), ty::ty_tup(bs)) {
14811485
if check vec::same_length(as, bs) {
1482-
map2(as, bs) {|a, b| self.tys(a, b) }.chain {|ts|
1486+
map_vec2(as, bs) {|a, b| self.tys(a, b) }.chain {|ts|
14831487
ok(ty::mk_tup(tcx, ts))
14841488
}
14851489
} else {

0 commit comments

Comments
 (0)