Skip to content

Commit

Permalink
toml: add Map::retain method
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospb19 committed Jun 28, 2023
1 parent 22fb58e commit 6fd86a8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/toml/src/map.rs
Expand Up @@ -138,6 +138,20 @@ impl Map<String, Value> {
self.map.remove(key)
}

/// Retains only the elements specified by the predicate.
///
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns
/// `false`.
///
/// The elements are visited in iteration order.
#[inline]
pub fn retain<F>(&mut self, keep: F)
where
F: FnMut(&String, &mut Value) -> bool,
{
self.map.retain(keep);
}

/// Gets the given key's corresponding entry in the map for in-place
/// manipulation.
pub fn entry<S>(&mut self, key: S) -> Entry<'_>
Expand Down

0 comments on commit 6fd86a8

Please sign in to comment.