LRUCache::new -> LRUCache::default.

MozReview-Commit-ID: KouOaYTluRx
This commit is contained in:
Bobby Holley 2017-09-20 19:00:15 -07:00
parent 8b6c5988b5
commit 13a3cf27a8
3 changed files with 6 additions and 5 deletions

View file

@ -33,9 +33,8 @@ pub struct Entry<T> {
next: u16,
}
impl<T, A: Array<Item=Entry<T>>> LRUCache<T, A> {
/// Create an empty LRU cache.
pub fn new() -> Self {
impl<T, A: Array<Item=Entry<T>>> Default for LRUCache<T, A> {
fn default() -> Self {
let cache = LRUCache {
entries: ArrayVec::new(),
head: 0,
@ -44,7 +43,9 @@ impl<T, A: Array<Item=Entry<T>>> LRUCache<T, A> {
assert!(cache.entries.capacity() < u16::max_value() as usize, "Capacity overflow");
cache
}
}
impl<T, A: Array<Item=Entry<T>>> LRUCache<T, A> {
/// Returns the number of elements in the cache.
pub fn num_entries(&self) -> usize {
self.entries.len()