Skip to content

Commit f571231

Browse files
committed
Remove the heapsize feature
It is not exposed, so never compiled. It's leftover from when lru_disk_cache was a separate crate.
1 parent 901923b commit f571231

File tree

1 file changed

+0
-53
lines changed

1 file changed

+0
-53
lines changed

src/lru_disk_cache/lru_cache.rs

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,6 @@
3737
//! assert!(cache.get_mut(&2).is_none());
3838
//! ```
3939
//!
40-
//! The cache can also be limited by an arbitrary metric calculated from its key-value pairs, see
41-
//! [`LruCache::with_meter`][with_meter] for more information. If the `heapsize` feature is enabled,
42-
//! this crate provides one such alternate metric—`HeapSize`. Custom metrics can be written by
43-
//! implementing the [`Meter`][meter] trait.
44-
//!
45-
//! [with_meter]: struct.LruCache.html#method.with_meter
46-
//! [meter]: trait.Meter.html
47-
48-
#[cfg(feature = "heapsize")]
49-
extern crate heapsize;
50-
5140
use std::borrow::Borrow;
5241
use std::collections::hash_map::RandomState;
5342
use std::fmt;
@@ -153,33 +142,6 @@ impl<K, V> CountableMeterWithMeasure<K, V, ()> for Count {
153142
}
154143
}
155144

156-
#[cfg(feature = "heapsize")]
157-
mod heap_meter {
158-
use heapsize::HeapSizeOf;
159-
use std::borrow::Borrow;
160-
161-
/// Size limit based on the heap size of each cache item.
162-
///
163-
/// Requires cache entries that implement [`HeapSizeOf`][1].
164-
///
165-
/// [1]: https://doc.servo.org/heapsize/trait.HeapSizeOf.html
166-
pub struct HeapSize;
167-
168-
impl<K, V: HeapSizeOf> super::Meter<K, V> for HeapSize {
169-
type Measure = usize;
170-
171-
fn measure<Q: ?Sized>(&self, _: &Q, item: &V) -> usize
172-
where
173-
K: Borrow<Q>,
174-
{
175-
item.heap_size_of_children() + ::std::mem::size_of::<V>()
176-
}
177-
}
178-
}
179-
180-
#[cfg(feature = "heapsize")]
181-
pub use heap_meter::*;
182-
183145
/// An LRU cache.
184146
#[derive(Clone)]
185147
pub struct LruCache<K: Eq + Hash, V, S: BuildHasher = RandomState, M: CountableMeter<K, V> = Count>
@@ -906,19 +868,4 @@ mod tests {
906868
assert!(!cache.contains_key("foo1"));
907869
assert!(!cache.contains_key("foo2"));
908870
}
909-
910-
#[cfg(feature = "heapsize")]
911-
#[test]
912-
fn test_heapsize_cache() {
913-
use super::HeapSize;
914-
915-
let mut cache = LruCache::<&str, (u8, u8, u8), _, _>::with_meter(8, HeapSize);
916-
cache.insert("foo1", (1, 2, 3));
917-
cache.insert("foo2", (4, 5, 6));
918-
cache.insert("foo3", (7, 8, 9));
919-
assert!(!cache.contains_key("foo1"));
920-
cache.insert("foo2", (10, 11, 12));
921-
cache.insert("foo4", (13, 14, 15));
922-
assert!(!cache.contains_key("foo3"));
923-
}
924871
}

0 commit comments

Comments
 (0)