From 45426c3b4c20b69b51e7f1866f3e893be273f34c Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Tue, 13 Aug 2013 21:29:16 -0400 Subject: 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. --- src/libstd/vec.rs | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) (limited to 'src/libstd') 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 @@ -390,39 +390,6 @@ pub fn unzip(v: ~[(T, U)]) -> (~[T], ~[U]) { (ts, us) } -/** - * Convert two vectors to a vector of pairs, by reference. As zip(). - */ -pub fn zip_slice(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(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`. * @@ -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); -- cgit 1.4.1-3-g733a5