Skip to content

Commit fbc77ec

Browse files
authored
Merge pull request #829 from tisonkun/map-get-kv
feat: impl Map get_key_value
2 parents 8efc81e + 4605a64 commit fbc77ec

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

crates/toml/src/map.rs

+13
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,19 @@ impl Map<String, Value> {
112112
self.map.get_mut(key)
113113
}
114114

115+
/// Returns the key-value pair matching the given key.
116+
///
117+
/// The key may be any borrowed form of the map's key type, but the ordering
118+
/// on the borrowed form *must* match the ordering on the key type.
119+
#[inline]
120+
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&String, &Value)>
121+
where
122+
String: Borrow<Q>,
123+
Q: ?Sized + Ord + Eq + Hash,
124+
{
125+
self.map.get_key_value(key)
126+
}
127+
115128
/// Inserts a key-value pair into the map.
116129
///
117130
/// If the map did not have this key present, `None` is returned.

0 commit comments

Comments
 (0)