about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-02-08 19:20:36 -0500
committerDaniel Micay <danielmicay@gmail.com>2013-02-08 19:20:36 -0500
commit0127828b5bc5363e30f6f672e0465b7fa79c9907 (patch)
treefad6dba4e7ca2b589e02af95057e90692c3fe9d3 /src/libstd
parenta32c5c73ee6aad9cb4b2e06867eafa09bc1ece3a (diff)
downloadrust-0127828b5bc5363e30f6f672e0465b7fa79c9907.tar.gz
rust-0127828b5bc5363e30f6f672e0465b7fa79c9907.zip
oldmap: separate out the methods that need Copy
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/oldmap.rs66
1 files changed, 34 insertions, 32 deletions
diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs
index fb594af4942..62ca25ed69d 100644
--- a/src/libstd/oldmap.rs
+++ b/src/libstd/oldmap.rs
@@ -76,7 +76,7 @@ pub mod chained {
         FoundAfter(@Entry<K,V>, @Entry<K,V>)
     }
 
-    priv impl<K:Eq IterBytes Hash, V: Copy> T<K, V> {
+    priv impl<K:Eq IterBytes Hash, V> T<K, V> {
         pure fn search_rem(k: &K, h: uint, idx: uint,
                            e_root: @Entry<K,V>) -> SearchResult<K,V> {
             let mut e0 = e_root;
@@ -172,7 +172,7 @@ pub mod chained {
         }
     }
 
-    impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V> {
+    impl<K: Eq IterBytes Hash, V> T<K, V> {
         pure fn contains_key(&self, k: &K) -> bool {
             let hash = k.hash_keyed(0,0) as uint;
             match self.search_tbl(k, hash) {
@@ -225,6 +225,38 @@ pub mod chained {
             }
         }
 
+        fn remove(k: &K) -> bool {
+            match self.search_tbl(k, k.hash_keyed(0,0) as uint) {
+              NotFound => false,
+              FoundFirst(idx, entry) => {
+                self.count -= 1u;
+                self.chains[idx] = entry.next;
+                true
+              }
+              FoundAfter(eprev, entry) => {
+                self.count -= 1u;
+                eprev.next = entry.next;
+                true
+              }
+            }
+        }
+
+        pure fn each(&self, blk: fn(key: &K, value: &V) -> bool) {
+            for self.each_entry |entry| {
+                if !blk(&entry.key, &entry.value) { break; }
+            }
+        }
+
+        pure fn each_key(&self, blk: fn(key: &K) -> bool) {
+            self.each(|k, _v| blk(k))
+        }
+
+        pure fn each_value(&self, blk: fn(value: &V) -> bool) {
+            self.each(|_k, v| blk(v))
+        }
+    }
+
+    impl<K: Eq IterBytes Hash Copy, V: Copy> T<K, V> {
         pure fn find(&self, k: &K) -> Option<V> {
             unsafe {
                 match self.search_tbl(k, k.hash_keyed(0,0) as uint) {
@@ -297,36 +329,6 @@ pub mod chained {
             }
             option::unwrap(move opt_v)
         }
-
-        fn remove(k: &K) -> bool {
-            match self.search_tbl(k, k.hash_keyed(0,0) as uint) {
-              NotFound => false,
-              FoundFirst(idx, entry) => {
-                self.count -= 1u;
-                self.chains[idx] = entry.next;
-                true
-              }
-              FoundAfter(eprev, entry) => {
-                self.count -= 1u;
-                eprev.next = entry.next;
-                true
-              }
-            }
-        }
-
-        pure fn each(&self, blk: fn(key: &K, value: &V) -> bool) {
-            for self.each_entry |entry| {
-                if !blk(&entry.key, &entry.value) { break; }
-            }
-        }
-
-        pure fn each_key(&self, blk: fn(key: &K) -> bool) {
-            self.each(|k, _v| blk(k))
-        }
-
-        pure fn each_value(&self, blk: fn(value: &V) -> bool) {
-            self.each(|_k, v| blk(v))
-        }
     }
 
     impl<K:Eq IterBytes Hash Copy ToStr, V: ToStr Copy> T<K, V> {