From ee2715d7b4cc470d5c522b1964e420b936f6bbba Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Wed, 29 Jun 2022 13:25:14 -0400 Subject: [PATCH] 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. --- src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 64b45de..921347a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1232,6 +1232,15 @@ impl SmallVec { 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 bool>(&mut self, f: F) { + self.retain(f) + } + /// Removes consecutive duplicate elements. pub fn dedup(&mut self) where