about summary refs log tree commit diff
path: root/src/libstd/hashmap.rs
diff options
context:
space:
mode:
authorblake2-ppc <blake2-ppc>2013-07-31 21:07:44 +0200
committerblake2-ppc <blake2-ppc>2013-08-01 16:54:22 +0200
commitb18bd785ec489c5c0ae9f84e8144a37e414cdee5 (patch)
tree1437f63026b4caec9695845d973a139bcd44122f /src/libstd/hashmap.rs
parent02bdf90cf6509f0f308ce133551a833c264b8960 (diff)
downloadrust-b18bd785ec489c5c0ae9f84e8144a37e414cdee5.tar.gz
rust-b18bd785ec489c5c0ae9f84e8144a37e414cdee5.zip
std: Replace `for` with `do { .. }` expr where internal iterators are used
Diffstat (limited to 'src/libstd/hashmap.rs')
-rw-r--r--src/libstd/hashmap.rs35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs
index b162869201d..8c06f23b8c1 100644
--- a/src/libstd/hashmap.rs
+++ b/src/libstd/hashmap.rs
@@ -130,15 +130,17 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
                                 hash: uint,
                                 k: &K)
                              -> SearchResult {
-        for self.bucket_sequence(hash) |i| {
+        let mut ret = TableFull;
+        do self.bucket_sequence(hash) |i| {
             match self.buckets[i] {
-                Some(ref bkt) => if bkt.hash == hash && *k == bkt.key {
-                    return FoundEntry(i);
+                Some(ref bkt) if bkt.hash == hash && *k == bkt.key => {
+                    ret = FoundEntry(i); false
                 },
-                None => return FoundHole(i)
+                None => { ret = FoundHole(i); false }
+                _ => true,
             }
-        }
-        TableFull
+        };
+        ret
     }
 
     #[inline]
@@ -146,17 +148,17 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
                                                   hash: uint,
                                                   k: &Q)
                                                -> SearchResult {
-        for self.bucket_sequence(hash) |i| {
+        let mut ret = TableFull;
+        do self.bucket_sequence(hash) |i| {
             match self.buckets[i] {
-                Some(ref bkt) => {
-                    if bkt.hash == hash && k.equiv(&bkt.key) {
-                        return FoundEntry(i);
-                    }
+                Some(ref bkt) if bkt.hash == hash && k.equiv(&bkt.key) => {
+                    ret = FoundEntry(i); false
                 },
-                None => return FoundHole(i)
+                None => { ret = FoundHole(i); false }
+                _ => true,
             }
-        }
-        TableFull
+        };
+        ret
     }
 
     /// Expand the capacity of the array to the next power of two
@@ -272,11 +274,6 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
 
         value
     }
-
-    fn search(&self, hash: uint,
-              op: &fn(x: &Option<Bucket<K, V>>) -> bool) {
-        let _ = self.bucket_sequence(hash, |i| op(&self.buckets[i]));
-    }
 }
 
 impl<K:Hash + Eq,V> Container for HashMap<K, V> {