mirror of
https://github.com/serde-rs/json.git
synced 2026-03-23 01:54:02 +00:00
Add Map::get_key_value method.
This commit is contained in:
13
src/map.rs
13
src/map.rs
@@ -94,6 +94,19 @@ impl Map<String, Value> {
|
||||
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<Q>(&self, key: &Q) -> Option<(&String, &Value)>
|
||||
where
|
||||
String: Borrow<Q>,
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user