From 499a443032aa5ff728e1c0c4220b1170b57a685c Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Wed, 26 Oct 2022 02:02:09 -0700 Subject: feat(tvix/eval): add NixList::force_elements() This adds a function NixList::force_elements() which forces each element of the list shallowly. This behavior is needed for `builtins.replaceStrings`, and probably a few other builtins as well. Signed-off-by: Adam Joseph Change-Id: I3f0681acbbfe50e781b5f07b6a441647f5e6f8da Reviewed-on: https://cl.tvl.fyi/c/depot/+/7094 Tested-by: BuildkiteCI Reviewed-by: tazjin --- tvix/eval/src/value/list.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tvix/eval/src/value/list.rs') diff --git a/tvix/eval/src/value/list.rs b/tvix/eval/src/value/list.rs index 66f7eb8108..8ea3db7aec 100644 --- a/tvix/eval/src/value/list.rs +++ b/tvix/eval/src/value/list.rs @@ -100,6 +100,11 @@ impl NixList { Ok(true) } + + /// force each element of the list (shallowly), making it safe to call .get().value() + pub fn force_elements(&self, vm: &mut VM) -> Result<(), ErrorKind> { + self.iter().try_for_each(|v| v.force(vm).map(|_| ())) + } } impl IntoIterator for NixList { -- cgit 1.4.1