Skip to content

Commit e9c2f0a

Browse files
cmyrmbrubeck
authored andcommitted
Add retain_mut method (as an alias to retain)
I was trying to use this crate as a drop-in replacement for std::Vec, where I am using the retain_mut method.
1 parent 4ce5e16 commit e9c2f0a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,15 @@ impl<A: Array> SmallVec<A> {
12321232
self.truncate(len - del);
12331233
}
12341234

1235+
/// Retains only the elements specified by the predicate.
1236+
///
1237+
/// This method is identical in behaviour to [`retain`]; it is included only
1238+
/// to maintain api-compatability with `std::Vec`, where the methods are
1239+
/// separate for historical reasons.
1240+
pub fn retain_mut<F: FnMut(&mut A::Item) -> bool>(&mut self, f: F) {
1241+
self.retain(f)
1242+
}
1243+
12351244
/// Removes consecutive duplicate elements.
12361245
pub fn dedup(&mut self)
12371246
where

0 commit comments

Comments
 (0)