From 85b3f17007825b023d549d8e926322797e08ce6d Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 5 Sep 2022 11:41:50 -0700 Subject: feat(tvix/eval): Support builtins.head TL;DR: - support `builtins.head` - define `ErrorKind::IndexOutOfBounds` and canonical error code - support basic unit tests Change-Id: I859107ffb4e220cba1be8c2ac41d1913dcca37ff Reviewed-on: https://cl.tvl.fyi/c/depot/+/6544 Reviewed-by: wpcarro Autosubmit: wpcarro Reviewed-by: sterni Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/eval/src/value/list.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tvix/eval/src/value') diff --git a/tvix/eval/src/value/list.rs b/tvix/eval/src/value/list.rs index da86fdda26ec..c00ddd4191ea 100644 --- a/tvix/eval/src/value/list.rs +++ b/tvix/eval/src/value/list.rs @@ -32,6 +32,10 @@ impl NixList { self.0.len() } + pub fn get(&self, i: usize) -> Option<&Value> { + self.0.get(i) + } + pub fn construct(count: usize, stack_slice: Vec) -> Self { debug_assert!( count == stack_slice.len(), -- cgit 1.4.1