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/libcore/send_map.rs | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'src/libcore/send_map.rs') diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index 28b36deb1d4..5dfc1f64367 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -17,7 +17,7 @@ trait SendMap { pure fn len(&const self) -> uint; pure fn is_empty(&const self) -> bool; pure fn contains_key(&const self, k: &K) -> bool; - pure fn each_ref(&self, blk: fn(k: &K, v: &V) -> bool); + pure fn each(&self, blk: fn(k: &K, v: &V) -> bool); pure fn each_key_ref(&self, blk: fn(k: &K) -> bool); pure fn each_value_ref(&self, blk: fn(v: &V) -> bool); pure fn find(&const self, k: &K) -> Option; @@ -311,7 +311,7 @@ mod linear { } } - pure fn each_ref(&self, blk: fn(k: &K, v: &V) -> bool) { + pure fn each(&self, blk: fn(k: &K, v: &V) -> bool) { for vec::each(self.buckets) |slot| { let mut broke = false; do slot.iter |bucket| { @@ -323,12 +323,12 @@ mod linear { } } - pure fn each_key_ref(&self, blk: fn(k: &K) -> bool) { - self.each_ref(|k, _v| blk(k)) + pure fn each_key(&self, blk: fn(k: &K) -> bool) { + self.each(|k, _v| blk(k)) } - pure fn each_value_ref(&self, blk: fn(v: &V) -> bool) { - self.each_ref(|_k, v| blk(v)) + pure fn each_value(&self, blk: fn(v: &V) -> bool) { + self.each(|_k, v| blk(v)) } } @@ -358,22 +358,6 @@ mod linear { } } - - impl LinearMap { - pure fn each(&self, blk: fn(+K,+V) -> bool) { - self.each_ref(|k,v| blk(copy *k, copy *v)); - } - } - impl LinearMap { - pure fn each_key(&self, blk: fn(+K) -> bool) { - self.each_key_ref(|k| blk(copy *k)); - } - } - impl LinearMap { - pure fn each_value(&self, blk: fn(+V) -> bool) { - self.each_value_ref(|v| blk(copy *v)); - } - } } #[test] @@ -438,8 +422,8 @@ mod test { } let mut observed = 0; for m.each |k, v| { - assert v == k*2; - observed |= (1 << k); + assert *v == *k * 2; + observed |= (1 << *k); } assert observed == 0xFFFF_FFFF; } -- cgit 1.4.1-3-g733a5