Added a get function to IndexMap

This commit is contained in:
2022-12-12 13:25:07 +01:00
parent 13e6454d3d
commit 6546cb54b5

View File

@@ -62,6 +62,14 @@ where
Self(HashMap::new())
}
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<Index>
where
K: Borrow<Q>,
Q: Hash + Eq + ToOwned<Owned = K>,
{
self.0.get(k).cloned()
}
pub fn get_or_create<Q: ?Sized>(&mut self, k: &Q) -> Index
where
K: Borrow<Q>,