From 184ff831e16ab2f3c60b9b05079566c9566cfc0b Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Mon, 26 Apr 2021 16:44:34 -0600 Subject: [PATCH] extend Map trait --- patch-db/src/model.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/patch-db/src/model.rs b/patch-db/src/model.rs index 1cc71de..bb304ce 100644 --- a/patch-db/src/model.rs +++ b/patch-db/src/model.rs @@ -231,15 +231,22 @@ impl Deserialize<'de>> HasModel for Vec { pub trait Map { type Key: AsRef; type Value; + fn get(&self, key: &Self::Key) -> Option<&Self::Value>; } -impl, V> Map for HashMap { +impl + Eq + Hash, V> Map for HashMap { type Key = K; type Value = V; + fn get(&self, key: &Self::Key) -> Option<&Self::Value> { + HashMap::get(self, key) + } } -impl, V> Map for BTreeMap { +impl + Ord, V> Map for BTreeMap { type Key = K; type Value = V; + fn get(&self, key: &Self::Key) -> Option<&Self::Value> { + self.get(key) + } } #[derive(Debug, Clone)]