Skip to content

Commit 4494c52

Browse files
committed
---
yaml --- r: 57195 b: refs/heads/try c: d53e686 h: refs/heads/master i: 57193: 0f9eb15 57191: 45edb94 v: v3
1 parent 376c2d8 commit 4494c52

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: c081ffbd1e845687202a975ea2e698b623e5722f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 79a2b2eafc3c766cecec8a5f76317693bae9ed17
5-
refs/heads/try: 91fb7b282de4877e72f22f42b4535e3c76732264
5+
refs/heads/try: d53e686f4f940ff87cc8bff3a2ebe81cc4022208
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ pub fn map_vec2<S,T,U:Copy,V:Copy>(ss: &[S], ts: &[T],
358358
359359
/**
360360
* Applies op to the pairwise elements from `ss` and `ts`, aborting on
361-
* error. This could be implemented using `map2()` but it is more efficient
361+
* error. This could be implemented using `map_zip()` but it is more efficient
362362
* on its own as no result vector is built.
363363
*/
364364
#[inline(always)]

branches/try/src/libcore/tuple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'self,A:Copy,B:Copy> ExtendedTupleOps<A,B> for (&'self [A], &'self [B]) {
123123
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C] {
124124
match *self {
125125
(ref a, ref b) => {
126-
vec::map2(*a, *b, f)
126+
vec::map_zip(*a, *b, f)
127127
}
128128
}
129129
}
@@ -144,7 +144,7 @@ impl<A:Copy,B:Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) {
144144
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C] {
145145
match *self {
146146
(ref a, ref b) => {
147-
vec::map2(*a, *b, f)
147+
vec::map_zip(*a, *b, f)
148148
}
149149
}
150150
}

branches/try/src/libcore/vec.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ pub fn from_slice<T:Copy>(t: &[T]) -> ~[T] {
173173
from_fn(t.len(), |i| t[i])
174174
}
175175

176-
/// Creates a new vector with a capacity of `capacity`
177176
pub fn with_capacity<T>(capacity: uint) -> ~[T] {
178177
let mut vec = ~[];
179178
reserve(&mut vec, capacity);
@@ -848,8 +847,11 @@ pub fn flat_map<T, U>(v: &[T], f: &fn(t: &T) -> ~[U]) -> ~[U] {
848847
result
849848
}
850849
851-
/// Apply a function to each pair of elements and return the results
852-
pub fn map2<T:Copy,U:Copy,V>(v0: &[T], v1: &[U],
850+
/**
851+
* Apply a function to each pair of elements and return the results.
852+
* Equivalent to `map(zip(v0, v1), f)`.
853+
*/
854+
pub fn map_zip<T:Copy,U:Copy,V>(v0: &[T], v1: &[U],
853855
f: &fn(t: &T, v: &U) -> V) -> ~[V] {
854856
let v0_len = len(v0);
855857
if v0_len != len(v1) { fail!(); }
@@ -1566,16 +1568,6 @@ pub fn each_permutation<T:Copy>(v: &[T], put: &fn(ts: &[T]) -> bool) {
15661568
}
15671569
}
15681570
1569-
// see doc below
1570-
#[cfg(stage0)] // XXX: lifetimes!
1571-
pub fn windowed<T>(n: uint, v: &[T], it: &fn(&[T]) -> bool) {
1572-
assert!(1u <= n);
1573-
if n > v.len() { return; }
1574-
for uint::range(0, v.len() - n + 1) |i| {
1575-
if !it(v.slice(i, i+n)) { return }
1576-
}
1577-
}
1578-
15791571
/**
15801572
* Iterate over all contiguous windows of length `n` of the vector `v`.
15811573
*
@@ -1590,6 +1582,14 @@ pub fn windowed<T>(n: uint, v: &[T], it: &fn(&[T]) -> bool) {
15901582
* ~~~
15911583
*
15921584
*/
1585+
#[cfg(stage0)] // XXX: lifetimes!
1586+
pub fn windowed<T>(n: uint, v: &[T], it: &fn(&[T]) -> bool) {
1587+
assert!(1u <= n);
1588+
if n > v.len() { return; }
1589+
for uint::range(0, v.len() - n + 1) |i| {
1590+
if !it(v.slice(i, i+n)) { return }
1591+
}
1592+
}
15931593
#[cfg(stage1)]
15941594
#[cfg(stage2)]
15951595
#[cfg(stage3)]
@@ -3399,12 +3399,12 @@ mod tests {
33993399
}
34003400

34013401
#[test]
3402-
fn test_map2() {
3402+
fn test_map_zip() {
34033403
fn times(x: &int, y: &int) -> int { *x * *y }
34043404
let f = times;
34053405
let v0 = ~[1, 2, 3, 4, 5];
34063406
let v1 = ~[5, 4, 3, 2, 1];
3407-
let u = map2::<int, int, int>(v0, v1, f);
3407+
let u = map_zip::<int, int, int>(v0, v1, f);
34083408
let mut i = 0;
34093409
while i < 5 { assert!(v0[i] * v1[i] == u[i]); i += 1; }
34103410
}
@@ -4338,10 +4338,10 @@ mod tests {
43384338
#[ignore(windows)]
43394339
#[should_fail]
43404340
#[allow(non_implicitly_copyable_typarams)]
4341-
fn test_map2_fail() {
4341+
fn test_map_zip_fail() {
43424342
let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
43434343
let mut i = 0;
4344-
do map2(v, v) |_elt1, _elt2| {
4344+
do map_zip(v, v) |_elt1, _elt2| {
43454345
if i == 2 {
43464346
fail!()
43474347
}

branches/try/src/librustc/middle/trans/monomorphize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ pub fn make_mono_id(ccx: @CrateContext,
356356
Some(vts) => {
357357
let item_ty = ty::lookup_item_type(ccx.tcx, item);
358358
let mut i = 0;
359-
vec::map2(*item_ty.generics.type_param_defs, substs, |type_param_def, subst| {
359+
vec::map_zip(*item_ty.generics.type_param_defs, substs, |type_param_def, subst| {
360360
let mut v = ~[];
361361
for type_param_def.bounds.each |bound| {
362362
match *bound {
@@ -376,7 +376,7 @@ pub fn make_mono_id(ccx: @CrateContext,
376376
};
377377
let param_ids = match param_uses {
378378
Some(ref uses) => {
379-
vec::map2(precise_param_ids, **uses, |id, uses| {
379+
vec::map_zip(precise_param_ids, **uses, |id, uses| {
380380
if ccx.sess.no_monomorphic_collapse() {
381381
match copy *id {
382382
(a, b) => mono_precise(a, b)

branches/try/src/librustdoc/attr_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ fn merge_method_attrs(
209209
}
210210
};
211211
212-
do vec::map2(docs, attrs) |doc, attrs| {
212+
do vec::map_zip(docs, attrs) |doc, attrs| {
213213
assert!(doc.name == attrs.first());
214214
let desc = attrs.second();
215215

branches/try/src/libsyntax/ext/deriving/generic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ impl<'self> MethodDef<'self> {
629629
}
630630
}
631631
let field_tuples =
632-
do vec::map2(*self_vec,
632+
do vec::map_zip(*self_vec,
633633
enum_matching_fields) |&(id, self_f), &other| {
634634
(id, self_f, other)
635635
};

branches/try/src/libsyntax/ext/pipes/pipec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl gen_send for message {
5757
assert!(next_state.tys.len() ==
5858
next.generics.ty_params.len());
5959
let arg_names = tys.mapi(|i, _ty| cx.ident_of(~"x_"+i.to_str()));
60-
let args_ast = vec::map2(arg_names, *tys, |n, t| cx.arg(*n, *t));
60+
let args_ast = vec::map_zip(arg_names, *tys, |n, t| cx.arg(*n, *t));
6161

6262
let pipe_ty = cx.ty_path_ast_builder(
6363
path(~[this.data_name()], span)
@@ -135,7 +135,7 @@ impl gen_send for message {
135135
debug!("pipec: no next state");
136136
let arg_names = tys.mapi(|i, _ty| (~"x_" + i.to_str()));
137137
138-
let args_ast = do vec::map2(arg_names, *tys) |n, t| {
138+
let args_ast = do vec::map_zip(arg_names, *tys) |n, t| {
139139
cx.arg(cx.ident_of(*n), *t)
140140
};
141141

branches/try/src/test/run-pass/block-vec-map2.rs renamed to branches/try/src/test/run-pass/block-vec-map_zip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern mod std;
1212

1313
pub fn main() {
1414
let v =
15-
vec::map2(~[1, 2, 3, 4, 5],
15+
vec::map_zip(~[1, 2, 3, 4, 5],
1616
~[true, false, false, true, true],
1717
|i, b| if *b { -(*i) } else { *i } );
1818
error!(v.clone());

0 commit comments

Comments
 (0)