From 4605a6422fa808d58ba55f6ff7d917ef96e88e72 Mon Sep 17 00:00:00 2001 From: tison Date: Wed, 5 Feb 2025 22:46:13 +0800 Subject: [PATCH] fea: impl Map get_key_value Signed-off-by: tison --- crates/toml/src/map.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/toml/src/map.rs b/crates/toml/src/map.rs index 311acb24..3cc47711 100644 --- a/crates/toml/src/map.rs +++ b/crates/toml/src/map.rs @@ -112,6 +112,19 @@ impl Map { self.map.get_mut(key) } + /// Returns the key-value pair matching the given key. + /// + /// The key may be any borrowed form of the map's key type, but the ordering + /// on the borrowed form *must* match the ordering on the key type. + #[inline] + pub fn get_key_value(&self, key: &Q) -> Option<(&String, &Value)> + where + String: Borrow, + Q: ?Sized + Ord + Eq + Hash, + { + self.map.get_key_value(key) + } + /// Inserts a key-value pair into the map. /// /// If the map did not have this key present, `None` is returned.