about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2022-10-26T09·02-0700
committerAdam Joseph <adam@westernsemico.com>2022-10-26T12·32+0000
commit499a443032aa5ff728e1c0c4220b1170b57a685c (patch)
tree89d0ed0bc1aa4b71c8261e94a9aa484da85ea750 /tvix
parentdc3543e0ca03b5954c4c740f984078f11e57b867 (diff)
feat(tvix/eval): add NixList::force_elements() r/5200
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 <adam@westernsemico.com>
Change-Id: I3f0681acbbfe50e781b5f07b6a441647f5e6f8da
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7094
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/src/value/list.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/tvix/eval/src/value/list.rs b/tvix/eval/src/value/list.rs
index 66f7eb8108e9..8ea3db7aecf3 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 {