From 84ba4bfa9498d0822617394c900d5cdd71f0fcd2 Mon Sep 17 00:00:00 2001 From: Ian Manske Date: Mon, 22 Apr 2024 18:06:08 -0400 Subject: [PATCH] Add `Record::retain_mut` implementation --- crates/nu-protocol/src/value/record.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/nu-protocol/src/value/record.rs b/crates/nu-protocol/src/value/record.rs index a204e5d78b..6f69ab1b5d 100644 --- a/crates/nu-protocol/src/value/record.rs +++ b/crates/nu-protocol/src/value/record.rs @@ -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.