]> git.lizzy.rs Git - rust.git/commitdiff
Rename vec::mod2 to vec::mod_zip
authorCorey Richardson <corey@octayn.net>
Thu, 25 Apr 2013 05:38:44 +0000 (01:38 -0400)
committerCorey Richardson <corey@octayn.net>
Thu, 25 Apr 2013 05:38:44 +0000 (01:38 -0400)
src/libcore/result.rs
src/libcore/tuple.rs
src/libcore/vec.rs
src/librustc/middle/trans/monomorphize.rs
src/librustdoc/attr_pass.rs
src/libsyntax/ext/deriving/generic.rs
src/libsyntax/ext/pipes/pipec.rs
src/test/run-pass/block-vec-map2.rs [deleted file]
src/test/run-pass/block-vec-map_zip.rs [new file with mode: 0644]

index 58e281c29c60565f2e5d640ed2106dae8ca34fbe..9171c5167bc7bbdbf13debc0d05aa69f8995ad60 100644 (file)
@@ -358,7 +358,7 @@ pub fn map_vec2<S,T,U:Copy,V:Copy>(ss: &[S], ts: &[T],
 
 /**
  * Applies op to the pairwise elements from `ss` and `ts`, aborting on
- * error.  This could be implemented using `map2()` but it is more efficient
+ * error.  This could be implemented using `map_zip()` but it is more efficient
  * on its own as no result vector is built.
  */
 #[inline(always)]
index 8e908435f3543fff15fea09f69d6d762f9ee5b5d..a2b6f0eb1a7143ff3218eb5437e3c1e72661467c 100644 (file)
@@ -123,7 +123,7 @@ fn zip(&self) -> ~[(A, B)] {
     fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C] {
         match *self {
             (ref a, ref b) => {
-                vec::map2(*a, *b, f)
+                vec::map_zip(*a, *b, f)
             }
         }
     }
@@ -144,7 +144,7 @@ fn zip(&self) -> ~[(A, B)] {
     fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C] {
         match *self {
             (ref a, ref b) => {
-                vec::map2(*a, *b, f)
+                vec::map_zip(*a, *b, f)
             }
         }
     }
index e478936ff65cc746529be05461976dae357252fa..cd944dcb18a11963bd35a8c9ec823d2269d6d79e 100644 (file)
@@ -847,8 +847,11 @@ pub fn flat_map<T, U>(v: &[T], f: &fn(t: &T) -> ~[U]) -> ~[U] {
     result
 }
 
-/// Apply a function to each pair of elements and return the results
-pub fn map2<T:Copy,U:Copy,V>(v0: &[T], v1: &[U],
+/**
+ * Apply a function to each pair of elements and return the results.
+ * Equivalent to `map(zip(v0, v1), f)`.
+ */
+pub fn map_zip<T:Copy,U:Copy,V>(v0: &[T], v1: &[U],
                                   f: &fn(t: &T, v: &U) -> V) -> ~[V] {
     let v0_len = len(v0);
     if v0_len != len(v1) { fail!(); }
@@ -3396,12 +3399,12 @@ fn test_map() {
     }
 
     #[test]
-    fn test_map2() {
+    fn test_map_zip() {
         fn times(x: &int, y: &int) -> int { *x * *y }
         let f = times;
         let v0 = ~[1, 2, 3, 4, 5];
         let v1 = ~[5, 4, 3, 2, 1];
-        let u = map2::<int, int, int>(v0, v1, f);
+        let u = map_zip::<int, int, int>(v0, v1, f);
         let mut i = 0;
         while i < 5 { assert!(v0[i] * v1[i] == u[i]); i += 1; }
     }
@@ -4335,10 +4338,10 @@ fn test_flat_map_fail() {
     #[ignore(windows)]
     #[should_fail]
     #[allow(non_implicitly_copyable_typarams)]
-    fn test_map2_fail() {
+    fn test_map_zip_fail() {
         let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
         let mut i = 0;
-        do map2(v, v) |_elt1, _elt2| {
+        do map_zip(v, v) |_elt1, _elt2| {
             if i == 2 {
                 fail!()
             }
index a7221297eca02d1a7d0be4e8109d0e2f10506dee..db422d1b1bf5598949b017929ce25e68e00d308c 100644 (file)
@@ -356,7 +356,7 @@ pub fn make_mono_id(ccx: @CrateContext,
       Some(vts) => {
         let item_ty = ty::lookup_item_type(ccx.tcx, item);
         let mut i = 0;
-        vec::map2(*item_ty.generics.type_param_defs, substs, |type_param_def, subst| {
+        vec::map_zip(*item_ty.generics.type_param_defs, substs, |type_param_def, subst| {
             let mut v = ~[];
             for type_param_def.bounds.each |bound| {
                 match *bound {
@@ -376,7 +376,7 @@ pub fn make_mono_id(ccx: @CrateContext,
     };
     let param_ids = match param_uses {
       Some(ref uses) => {
-        vec::map2(precise_param_ids, **uses, |id, uses| {
+        vec::map_zip(precise_param_ids, **uses, |id, uses| {
             if ccx.sess.no_monomorphic_collapse() {
                 match copy *id {
                     (a, b) => mono_precise(a, b)
index a666bff18c97c7a494b3314888485d81de4fd595..49338291a7c85df3b636b16488dc9c8e577992d7 100644 (file)
@@ -209,7 +209,7 @@ fn merge_method_attrs(
         }
     };
 
-    do vec::map2(docs, attrs) |doc, attrs| {
+    do vec::map_zip(docs, attrs) |doc, attrs| {
         assert!(doc.name == attrs.first());
         let desc = attrs.second();
 
index dfbb98fa23388394884a3af0959fb2dd00d48d35..461c99e8442e9910aceed4c9cdfc529b79e96197 100644 (file)
@@ -629,7 +629,7 @@ fn build_enum_match(&self,
                                 }
                             }
                             let field_tuples =
-                                do vec::map2(*self_vec,
+                                do vec::map_zip(*self_vec,
                                              enum_matching_fields) |&(id, self_f), &other| {
                                 (id, self_f, other)
                             };
index ca8a17dad67c007d054ac5d348030a9858e53547..105e08e5fb459ba0493c759861045fa317d4d761 100644 (file)
@@ -57,7 +57,7 @@ fn gen_send(&mut self, cx: @ext_ctxt, try: bool) -> @ast::item {
             assert!(next_state.tys.len() ==
                 next.generics.ty_params.len());
             let arg_names = tys.mapi(|i, _ty| cx.ident_of(~"x_"+i.to_str()));
-            let args_ast = vec::map2(arg_names, *tys, |n, t| cx.arg(*n, *t));
+            let args_ast = vec::map_zip(arg_names, *tys, |n, t| cx.arg(*n, *t));
 
             let pipe_ty = cx.ty_path_ast_builder(
                 path(~[this.data_name()], span)
@@ -135,7 +135,7 @@ fn gen_send(&mut self, cx: @ext_ctxt, try: bool) -> @ast::item {
                 debug!("pipec: no next state");
                 let arg_names = tys.mapi(|i, _ty| (~"x_" + i.to_str()));
 
-                let args_ast = do vec::map2(arg_names, *tys) |n, t| {
+                let args_ast = do vec::map_zip(arg_names, *tys) |n, t| {
                     cx.arg(cx.ident_of(*n), *t)
                 };
 
diff --git a/src/test/run-pass/block-vec-map2.rs b/src/test/run-pass/block-vec-map2.rs
deleted file mode 100644 (file)
index d4783e1..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-extern mod std;
-
-pub fn main() {
-    let v =
-        vec::map2(~[1, 2, 3, 4, 5],
-                  ~[true, false, false, true, true],
-                  |i, b| if *b { -(*i) } else { *i } );
-    error!(v.clone());
-    assert!((v == ~[-1, 2, 3, -4, -5]));
-}
diff --git a/src/test/run-pass/block-vec-map_zip.rs b/src/test/run-pass/block-vec-map_zip.rs
new file mode 100644 (file)
index 0000000..5d637ba
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+extern mod std;
+
+pub fn main() {
+    let v =
+        vec::map_zip(~[1, 2, 3, 4, 5],
+                  ~[true, false, false, true, true],
+                  |i, b| if *b { -(*i) } else { *i } );
+    error!(v.clone());
+    assert!((v == ~[-1, 2, 3, -4, -5]));
+}