From 9cf271fe96b474d514b1052935db70c4056cf076 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 18 Sep 2012 21:41:37 -0700 Subject: 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. --- src/libstd/smallintmap.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/libstd/smallintmap.rs') 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 SmallIntMap: map::Map { fn get(+key: uint) -> V { get(self, key) } pure fn find(+key: uint) -> Option { 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(); -- cgit 1.4.1-3-g733a5