From 6546cb54b5b8a0bb2ff1255a7e7cb0e0b7eaf5a1 Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Mon, 12 Dec 2022 13:25:07 +0100 Subject: [PATCH] Added a get function to IndexMap --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 1890230..2f3f1af 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,6 +62,14 @@ where Self(HashMap::new()) } + pub fn get(&self, k: &Q) -> Option + where + K: Borrow, + Q: Hash + Eq + ToOwned, + { + self.0.get(k).cloned() + } + pub fn get_or_create(&mut self, k: &Q) -> Index where K: Borrow,