Skip to content

Commit

Permalink
Reorder Map::retain to keep keys() and values() adjacent
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Nov 13, 2021
1 parent 37da27f commit 24f85d2
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 24f85d2

Please sign in to comment.