From 84a6b888c05cea0bfdebd825d425ba5cbee4772a Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Fri, 19 Aug 2011 16:14:38 -0700 Subject: [PATCH] Add an iter2 iterator to vec. --- src/lib/vec.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib/vec.rs b/src/lib/vec.rs index 71d0be56f2b..a2222dfbf21 100644 --- a/src/lib/vec.rs +++ b/src/lib/vec.rs @@ -307,6 +307,14 @@ fn reversed<@T>(v: &[T]) -> [T] { ret rs; } +// Iterate over a list with with the indexes +iter iter2<@T>(v: &[T]) -> (uint, T) { + let i = 0u; + for x in v { + put (i, x); + i += 1u; + } +} mod unsafe { type ivec_repr =