diff options
author | Jack Moffitt <jack@metajack.im> | 2013-12-20 22:04:46 -0700 |
---|---|---|
committer | Jack Moffitt <jack@metajack.im> | 2014-01-12 19:45:45 -0700 |
commit | a7ef1cd35e9347a285f245041db4eb94047f4ab0 (patch) | |
tree | a6dc269d9f3cb031d7ea096628c81b7edc971c1c /src/components/util/cache.rs | |
parent | 728fb9a7dedf67445e7f12eafb314117efede70d (diff) | |
download | servo-a7ef1cd35e9347a285f245041db4eb94047f4ab0.tar.gz servo-a7ef1cd35e9347a285f245041db4eb94047f4ab0.zip |
Upgrade to latest Rust.
Diffstat (limited to 'src/components/util/cache.rs')
-rw-r--r-- | src/components/util/cache.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/components/util/cache.rs b/src/components/util/cache.rs index 02859014bbd..b8c89a3ac90 100644 --- a/src/components/util/cache.rs +++ b/src/components/util/cache.rs @@ -7,7 +7,7 @@ use std::hashmap::HashMap; pub trait Cache<K: Eq, V: Clone> { fn insert(&mut self, key: K, value: V); fn find(&mut self, key: &K) -> Option<V>; - fn find_or_create(&mut self, key: &K, blk: &fn(&K) -> V) -> V; + fn find_or_create(&mut self, key: &K, blk: |&K| -> V) -> V; fn evict_all(&mut self); } @@ -33,7 +33,7 @@ impl<K: Clone + Eq, V: Clone> Cache<K,V> for MonoCache<K,V> { } } - fn find_or_create(&mut self, key: &K, blk: &fn(&K) -> V) -> V { + fn find_or_create(&mut self, key: &K, blk: |&K| -> V) -> V { match self.find(key) { Some(value) => value, None => { @@ -87,7 +87,7 @@ impl<K: Clone + Eq + Hash, V: Clone> Cache<K,V> for HashCache<K,V> { } } - fn find_or_create(&mut self, key: &K, blk: &fn(&K) -> V) -> V { + fn find_or_create(&mut self, key: &K, blk: |&K| -> V) -> V { self.entries.find_or_insert_with(key.clone(), blk).clone() } @@ -149,7 +149,7 @@ impl<K: Clone + Eq, V: Clone> Cache<K,V> for LRUCache<K,V> { } } - fn find_or_create(&mut self, key: &K, blk: &fn(&K) -> V) -> V { + fn find_or_create(&mut self, key: &K, blk: |&K| -> V) -> V { match self.entries.iter().position(|&(ref k, _)| *k == *key) { Some(pos) => self.touch(pos), None => { @@ -191,7 +191,7 @@ fn test_lru_cache() { assert!(cache.find(&4).is_some()); // (2, 4) (no change) // Test find_or_create. - do cache.find_or_create(&1) |_| { one }; // (4, 1) + cache.find_or_create(&1, |_| { one }); // (4, 1) assert!(cache.find(&1).is_some()); // (4, 1) (no change) assert!(cache.find(&2).is_none()); // (4, 1) (no change) |