about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-08-13 21:29:16 -0400
committerDaniel Micay <danielmicay@gmail.com>2013-08-15 21:12:34 -0400
commit45426c3b4c20b69b51e7f1866f3e893be273f34c (patch)
tree86976aaf418b7e4a4cea567fa423197bd7ec690e /src/libstd
parent1f89eb867a33b25c3df0078eb2ec18d1fc00bc43 (diff)
downloadrust-45426c3b4c20b69b51e7f1866f3e893be273f34c.tar.gz
rust-45426c3b4c20b69b51e7f1866f3e893be273f34c.zip
vec: rm obsolete zip and zip_slice
These are obsoleted by the generic iterator `zip` adaptor. Unlike
these, it does not clone the elements or allocate a new vector by
default.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/vec.rs42
1 files changed, 1 insertions, 41 deletions
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);