Skip to content

Commit

Permalink
Add retain_mut method (as an alias to retain)
Browse files Browse the repository at this point in the history
I was trying to use this crate as a drop-in replacement for std::Vec,
where I am using the retain_mut method.
  • Loading branch information
cmyr authored and mbrubeck committed Jun 29, 2022
1 parent 4ce5e16 commit e9c2f0a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,15 @@ impl<A: Array> SmallVec<A> {
self.truncate(len - del);
}

/// Retains only the elements specified by the predicate.
///
/// This method is identical in behaviour to [`retain`]; it is included only
/// to maintain api-compatability with `std::Vec`, where the methods are
/// separate for historical reasons.
pub fn retain_mut<F: FnMut(&mut A::Item) -> bool>(&mut self, f: F) {
self.retain(f)
}

/// Removes consecutive duplicate elements.
pub fn dedup(&mut self)
where
Expand Down

0 comments on commit e9c2f0a

Please sign in to comment.