about summary refs log tree commit diff
path: root/src/lib
diff options
context:
space:
mode:
authorMichael Sullivan <sully@msully.net>2011-08-19 16:14:38 -0700
committerMichael Sullivan <sully@msully.net>2011-08-19 16:14:38 -0700
commit84a6b888c05cea0bfdebd825d425ba5cbee4772a (patch)
treea2a2f5975fa9cbc3467bbc2b35927169dc3e647c /src/lib
parent56c8d16326b2263ded277df1a19b9d25be8dc190 (diff)
Add an iter2 iterator to vec.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/vec.rs8
1 files changed, 8 insertions, 0 deletions
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 =