Skip to content

Commit 6d83090

Browse files
committed
impl Debug for LruCache
1 parent 4ad4ab4 commit 6d83090

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/lru_cache.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::{
22
borrow::Borrow,
3+
fmt,
34
hash::{BuildHasher, Hash},
45
usize,
56
};
@@ -277,3 +278,9 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> IntoIterator for &'a mut LruCache<K, V
277278
self.iter_mut()
278279
}
279280
}
281+
282+
impl<A: fmt::Debug + Hash + Eq, B: fmt::Debug, S: BuildHasher> fmt::Debug for LruCache<A, B, S> {
283+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
284+
f.debug_map().entries(self.iter().rev()).finish()
285+
}
286+
}

0 commit comments

Comments
 (0)