about summary refs log tree commit diff
path: root/src/libstd/smallintmap.rs
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-09-18 21:41:37 -0700
committerNiko Matsakis <niko@alum.mit.edu>2012-09-19 10:52:59 -0700
commit9cf271fe96b474d514b1052935db70c4056cf076 (patch)
tree7a6fb31efeaa4de91317c16aca824153aaaf988c /src/libstd/smallintmap.rs
parent62b7f4d800325b46002c47d23b58a9f2b7fabb9b (diff)
downloadrust-9cf271fe96b474d514b1052935db70c4056cf076.tar.gz
rust-9cf271fe96b474d514b1052935db70c4056cf076.zip
De-mode vec::each() and many of the str iteration routines
Note that the method foo.each() is not de-moded, nor the other
vec routines.
Diffstat (limited to 'src/libstd/smallintmap.rs')
-rw-r--r--src/libstd/smallintmap.rs14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs
index ab4d46d2d8b..5366774db37 100644
--- a/src/libstd/smallintmap.rs
+++ b/src/libstd/smallintmap.rs
@@ -103,21 +103,15 @@ impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> {
     fn get(+key: uint) -> V { get(self, key) }
     pure fn find(+key: uint) -> Option<V> { find(self, key) }
     fn rehash() { fail }
+
     pure fn each(it: fn(+key: uint, +value: V) -> bool) {
-        let mut idx = 0u, l = self.v.len();
-        while idx < l {
-            match self.v.get_elt(idx) {
-              Some(elt) => if !it(idx, elt) { break },
-              None => ()
-            }
-            idx += 1u;
-        }
+        self.each_ref(|k, v| it(*k, *v))
     }
     pure fn each_key(it: fn(+key: uint) -> bool) {
-        self.each(|k, _v| it(k))
+        self.each_ref(|k, _v| it(*k))
     }
     pure fn each_value(it: fn(+value: V) -> bool) {
-        self.each(|_k, v| it(v))
+        self.each_ref(|_k, v| it(*v))
     }
     pure fn each_ref(it: fn(key: &uint, value: &V) -> bool) {
         let mut idx = 0u, l = self.v.len();