Add Records::retain

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
This commit is contained in:
Jiahao XU 2025-06-10 16:30:37 +10:00 committed by GitHub
parent 4ec96064b6
commit 339713f989
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -214,6 +214,10 @@ impl Records {
self.data.remove(value.as_ref()) self.data.remove(value.as_ref())
} }
pub fn retain(&mut self, mut f: impl FnMut(&CrateInfo) -> bool) {
self.data.retain(|data| f(&data.crate_info))
}
pub fn take(&mut self, value: impl AsRef<str>) -> Option<CrateInfo> { pub fn take(&mut self, value: impl AsRef<str>) -> Option<CrateInfo> {
self.data.take(value.as_ref()).map(CrateInfo::from) self.data.take(value.as_ref()).map(CrateInfo::from)
} }