]> git.lizzy.rs Git - rust.git/blobdiff - src/libcollections/lru_cache.rs
use TotalEq for HashMap
[rust.git] / src / libcollections / lru_cache.rs
index 28ea36fa2317a2a2597d47e05ff626bfae3beb6a..e328b41cc0fff83cc06b093fa2caf7fe0e711141 100644 (file)
@@ -74,6 +74,8 @@ fn eq(&self, other: &KeyRef<K>) -> bool {
     }
 }
 
+impl<K: TotalEq> TotalEq for KeyRef<K> {}
+
 impl<K, V> LruEntry<K, V> {
     fn new() -> LruEntry<K, V> {
         LruEntry {
@@ -94,7 +96,7 @@ fn with_key_value(k: K, v: V) -> LruEntry<K, V> {
     }
 }
 
-impl<K: Hash + Eq, V> LruCache<K, V> {
+impl<K: Hash + TotalEq, V> LruCache<K, V> {
     /// Create an LRU Cache that holds at most `capacity` items.
     pub fn new(capacity: uint) -> LruCache<K, V> {
         let cache = LruCache {
@@ -218,7 +220,7 @@ fn attach(&mut self, node: *mut LruEntry<K, V>) {
     }
 }
 
-impl<A: fmt::Show + Hash + Eq, B: fmt::Show> fmt::Show for LruCache<A, B> {
+impl<A: fmt::Show + Hash + TotalEq, B: fmt::Show> fmt::Show for LruCache<A, B> {
     /// Return a string that lists the key-value pairs from most-recently
     /// used to least-recently used.
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -247,14 +249,14 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-impl<K: Hash + Eq, V> Container for LruCache<K, V> {
+impl<K: Hash + TotalEq, V> Container for LruCache<K, V> {
     /// Return the number of key-value pairs in the cache.
     fn len(&self) -> uint {
         self.map.len()
     }
 }
 
-impl<K: Hash + Eq, V> Mutable for LruCache<K, V> {
+impl<K: Hash + TotalEq, V> Mutable for LruCache<K, V> {
     /// Clear the cache of all key-value pairs.
     fn clear(&mut self) {
         self.map.clear();