Add Record::retain_mut implementation

This commit is contained in:
Ian Manske 2024-04-22 18:06:08 -04:00
parent 50313b89c1
commit 84ba4bfa94

View File

@ -183,8 +183,10 @@ impl Record {
where
F: FnMut(&str, &mut Value) -> bool,
{
todo!()
// self.inner.retain_mut(|(col, val)| keep(col, val));
self.inner = std::mem::take(&mut self.inner)
.into_iter()
.filter_map(|(col, mut val)| keep(&col, &mut val).then_some((col, val)))
.collect();
}
/// Truncate record to the first `len` elements.