about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libextra/sort.rs7
-rw-r--r--src/libextra/test.rs11
-rw-r--r--src/libstd/vec.rs42
-rw-r--r--src/test/run-pass/zip-same-length.rs44
4 files changed, 4 insertions, 100 deletions
diff --git a/src/libextra/sort.rs b/src/libextra/sort.rs
index c7920e72708..bea7868fd32 100644
--- a/src/libextra/sort.rs
+++ b/src/libextra/sort.rs
@@ -782,11 +782,8 @@ mod test_qsort3 {
 
 #[cfg(test)]
 mod test_qsort {
-
     use sort::*;
 
-    use std::vec;
-
     fn check_sort(v1: &mut [int], v2: &mut [int]) {
         let len = v1.len();
         fn leual(a: &int, b: &int) -> bool { *a <= *b }
@@ -835,9 +832,7 @@ mod test_qsort {
 
         let immut_names = names;
 
-        let pairs = vec::zip_slice(expected, immut_names);
-        for p in pairs.iter() {
-            let (a, b) = *p;
+        for (&a, &b) in expected.iter().zip(immut_names.iter()) {
             debug!("%d %d", a, b);
             assert_eq!(a, b);
         }
diff --git a/src/libextra/test.rs b/src/libextra/test.rs
index a9c3bf98cb6..9778248f005 100644
--- a/src/libextra/test.rs
+++ b/src/libextra/test.rs
@@ -1121,7 +1121,6 @@ mod tests {
 
     use std::either;
     use std::comm::{stream, SharedChan};
-    use std::vec;
     use tempfile;
     use std::os;
 
@@ -1309,14 +1308,8 @@ mod tests {
               ~"test::parse_ignored_flag",
               ~"test::sort_tests"];
 
-        let pairs = vec::zip(expected, filtered);
-
-        for p in pairs.iter() {
-            match *p {
-                (ref a, ref b) => {
-                    assert!(*a == b.desc.name.to_str());
-                }
-            }
+        for (a, b) in expected.iter().zip(filtered.iter()) {
+            assert!(*a == b.desc.name.to_str());
         }
     }
 
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index a605ea4373f..996b00096a2 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -391,39 +391,6 @@ pub fn unzip<T,U>(v: ~[(T, U)]) -> (~[T], ~[U]) {
 }
 
 /**
- * Convert two vectors to a vector of pairs, by reference. As zip().
- */
-pub fn zip_slice<T:Clone,U:Clone>(v: &[T], u: &[U]) -> ~[(T, U)] {
-    let mut zipped = ~[];
-    let sz = v.len();
-    let mut i = 0u;
-    assert_eq!(sz, u.len());
-    while i < sz {
-        zipped.push((v[i].clone(), u[i].clone()));
-        i += 1u;
-    }
-    zipped
-}
-
-/**
- * Convert two vectors to a vector of pairs.
- *
- * Returns a vector of tuples, where the i-th tuple contains the
- * i-th elements from each of the input vectors.
- */
-pub fn zip<T, U>(mut v: ~[T], mut u: ~[U]) -> ~[(T, U)] {
-    let mut i = v.len();
-    assert_eq!(i, u.len());
-    let mut w = with_capacity(i);
-    while i > 0 {
-        w.push((v.pop(),u.pop()));
-        i -= 1;
-    }
-    w.reverse();
-    w
-}
-
-/**
  * Iterate over all permutations of vector `v`.
  *
  * Permutations are produced in lexicographic order with respect to the order
@@ -2865,14 +2832,7 @@ mod tests {
 
     #[test]
     fn test_zip_unzip() {
-        let v1 = ~[1, 2, 3];
-        let v2 = ~[4, 5, 6];
-
-        let z1 = zip(v1, v2);
-
-        assert_eq!((1, 4), z1[0]);
-        assert_eq!((2, 5), z1[1]);
-        assert_eq!((3, 6), z1[2]);
+        let z1 = ~[(1, 4), (2, 5), (3, 6)];
 
         let (left, right) = unzip(z1);
 
diff --git a/src/test/run-pass/zip-same-length.rs b/src/test/run-pass/zip-same-length.rs
deleted file mode 100644
index d97148746d0..00000000000
--- a/src/test/run-pass/zip-same-length.rs
+++ /dev/null
@@ -1,44 +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.
-
-// In this case, the code should compile and should
-// succeed at runtime
-
-use std::vec;
-
-fn enum_chars(start: u8, end: u8) -> ~[char] {
-    assert!(start < end);
-    let mut i = start;
-    let mut r = ~[];
-    while i <= end { r.push(i as char); i += 1u as u8; }
-    return r;
-}
-
-fn enum_uints(start: uint, end: uint) -> ~[uint] {
-    assert!(start < end);
-    let mut i = start;
-    let mut r = ~[];
-    while i <= end { r.push(i); i += 1u; }
-    return r;
-}
-
-pub fn main() {
-    let a = 'a' as u8;
-    let j = 'j' as u8;
-    let k = 1u;
-    let l = 10u;
-    let chars = enum_chars(a, j);
-    let ints = enum_uints(k, l);
-
-    let ps = vec::zip(chars, ints);
-
-    assert_eq!(ps.head(), &('a', 1u));
-    assert_eq!(ps.last(), &(j as char, 10u));
-}