Skip to content

Commit 24f85d2

Browse files
committed
Reorder Map::retain to keep keys() and values() adjacent
1 parent 37da27f commit 24f85d2

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/map.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,6 @@ impl Map<String, Value> {
234234
}
235235
}
236236

237-
/// Retains only the elements specified by the predicate.
238-
///
239-
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)`
240-
/// returns `false`.
241-
#[cfg(not(no_btreemap_retain))]
242-
#[inline]
243-
pub fn retain<F>(&mut self, f: F)
244-
where
245-
F: FnMut(&String, &mut Value) -> bool,
246-
{
247-
self.map.retain(f);
248-
}
249-
250237
/// Gets an iterator over the values of the map.
251238
#[inline]
252239
pub fn values(&self) -> Values {
@@ -262,6 +249,19 @@ impl Map<String, Value> {
262249
iter: self.map.values_mut(),
263250
}
264251
}
252+
253+
/// Retains only the elements specified by the predicate.
254+
///
255+
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)`
256+
/// returns `false`.
257+
#[cfg(not(no_btreemap_retain))]
258+
#[inline]
259+
pub fn retain<F>(&mut self, f: F)
260+
where
261+
F: FnMut(&String, &mut Value) -> bool,
262+
{
263+
self.map.retain(f);
264+
}
265265
}
266266

267267
#[allow(clippy::derivable_impls)] // clippy bug: https://github.com/rust-lang/rust-clippy/issues/7655

0 commit comments

Comments
 (0)