mirror of
https://github.com/serde-rs/json.git
synced 2026-03-27 13:46:16 +00:00
Reorder Map::retain to keep keys() and values() adjacent
This commit is contained in:
26
src/map.rs
26
src/map.rs
@@ -234,19 +234,6 @@ impl Map<String, Value> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Retains only the elements specified by the predicate.
|
||||
///
|
||||
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)`
|
||||
/// returns `false`.
|
||||
#[cfg(not(no_btreemap_retain))]
|
||||
#[inline]
|
||||
pub fn retain<F>(&mut self, f: F)
|
||||
where
|
||||
F: FnMut(&String, &mut Value) -> bool,
|
||||
{
|
||||
self.map.retain(f);
|
||||
}
|
||||
|
||||
/// Gets an iterator over the values of the map.
|
||||
#[inline]
|
||||
pub fn values(&self) -> Values {
|
||||
@@ -262,6 +249,19 @@ impl Map<String, Value> {
|
||||
iter: self.map.values_mut(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Retains only the elements specified by the predicate.
|
||||
///
|
||||
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)`
|
||||
/// returns `false`.
|
||||
#[cfg(not(no_btreemap_retain))]
|
||||
#[inline]
|
||||
pub fn retain<F>(&mut self, f: F)
|
||||
where
|
||||
F: FnMut(&String, &mut Value) -> bool,
|
||||
{
|
||||
self.map.retain(f);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::derivable_impls)] // clippy bug: https://github.com/rust-lang/rust-clippy/issues/7655
|
||||
|
||||
Reference in New Issue
Block a user