summaryrefslogtreecommitdiffstats
path: root/vendor/clru/src/weight.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/clru/src/weight.rs')
-rw-r--r--vendor/clru/src/weight.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/vendor/clru/src/weight.rs b/vendor/clru/src/weight.rs
new file mode 100644
index 000000000..59c8a5688
--- /dev/null
+++ b/vendor/clru/src/weight.rs
@@ -0,0 +1,16 @@
+/// Trait used to retrieve the weight of a key-value pair.
+pub trait WeightScale<K, V> {
+ /// Returns the weight of a key-value pair.
+ fn weight(&self, key: &K, value: &V) -> usize;
+}
+
+/// A scale that always return 0.
+#[derive(Clone, Copy, Debug, Default)]
+pub struct ZeroWeightScale;
+
+impl<K, V> WeightScale<K, V> for ZeroWeightScale {
+ #[inline]
+ fn weight(&self, _: &K, _: &V) -> usize {
+ 0
+ }
+}