Update crates and added methods to get a key or all keys in an IndexMap

This commit is contained in:
2022-12-12 10:50:59 +01:00
parent 18d55a8ccf
commit 13e6454d3d
2 changed files with 14 additions and 3 deletions

View File

@@ -77,6 +77,17 @@ where
idx
}
}
pub fn key(&self, idx: Index) -> Option<&K> {
self.0
.iter()
.find(|(_, &value)| value == idx)
.map(|(key, _)| key)
}
pub fn keys(&self) -> impl Iterator<Item = &K> {
self.0.keys()
}
}
impl<K> Default for IndexMap<K>