From 13e6454d3d88bb509bb54c467fbda3637899d0ca Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Mon, 12 Dec 2022 10:50:59 +0100 Subject: [PATCH] Update crates and added methods to get a key or all keys in an IndexMap --- Cargo.toml | 6 +++--- src/lib.rs | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 91210be..d579204 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,9 +7,9 @@ edition = "2021" approx = { version = "0.5.1", optional = true } [dev-dependencies] -plotters = { version = "0.3.1", default-features = false, features = ["svg_backend", "all_elements", "all_series"] } -plotters-backend = "0.3.2" -time = { version = "0.3.9", features = ["parsing"] } +plotters = { version = "0.3.4", default-features = false, features = ["svg_backend", "all_elements", "all_series"] } +plotters-backend = "0.3.4" +time = { version = "0.3.17", features = ["parsing"] } trueskill-tt = { path = ".", features = ["approx"] } [profile.release] diff --git a/src/lib.rs b/src/lib.rs index 1fc6b7b..1890230 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 { + self.0.keys() + } } impl Default for IndexMap