about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorgamazeps <gamaz3ps@gmail.com>2014-11-08 01:40:20 +0100
committergamazeps <gamaz3ps@gmail.com>2014-11-08 15:02:09 +0100
commita11f16739f08ec480263ba549d510fffc8ce557e (patch)
treeaabc9d4b9fc8aef5405aa758ab8f3f659f6942b8 /src/libstd
parent16c8cd931cd5ccc9c73b87cac488938556018019 (diff)
downloadrust-a11f16739f08ec480263ba549d510fffc8ce557e.tar.gz
rust-a11f16739f08ec480263ba549d510fffc8ce557e.zip
Implements Extend for EnumSet and LruCache
Part of #18424
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/collections/lru_cache.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libstd/collections/lru_cache.rs b/src/libstd/collections/lru_cache.rs
index aab0924e7e4..94bea37d187 100644
--- a/src/libstd/collections/lru_cache.rs
+++ b/src/libstd/collections/lru_cache.rs
@@ -41,7 +41,7 @@ use cmp::{PartialEq, Eq};
 use collections::HashMap;
 use fmt;
 use hash::Hash;
-use iter::{range, Iterator};
+use iter::{range, Iterator, Extend};
 use mem;
 use ops::Drop;
 use option::{Some, None, Option};
@@ -329,6 +329,15 @@ impl<K: Hash + Eq, V> LruCache<K, V> {
     /// Clear the cache of all key-value pairs.
     #[unstable = "matches collection reform specification, waiting for dust to settle"]
     pub fn clear(&mut self) { self.map.clear(); }
+
+}
+
+impl<K: Hash + Eq, V> Extend<(K, V)> for LruCache<K, V> {
+    fn extend<T: Iterator<(K, V)>>(&mut self, mut iter: T) {
+        for (k, v) in iter{
+            self.insert(k, v);
+        }
+    }
 }
 
 impl<A: fmt::Show + Hash + Eq, B: fmt::Show> fmt::Show for LruCache<A, B> {