feat(tvix/eval): Support builtins.attrNames

Define `.len()` method on `NixAttrs` to preallocate the capacity of the result
vector.

Also anchor an errant comment to its context (I think).

Change-Id: I268f15025d453d7b3ae1146558c80e51433dd2a8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6546
Reviewed-by: wpcarro <wpcarro@gmail.com>
Reviewed-by: sterni <sternenseemann@systemli.org>
Autosubmit: wpcarro <wpcarro@gmail.com>
Tested-by: BuildkiteCI
This commit is contained in:
William Carroll 2022-09-05 11:43:17 -07:00 committed by clbot
parent 04503cf063
commit e834a2cbc4
4 changed files with 36 additions and 2 deletions

View file

@ -0,0 +1 @@
[ [ ] [ "bar" "baz" "foo" ] [ "Baz" "Foo" "bar" ] [ "Eric Idle" "Graham Chapman" "John Cleese" "Michael Palin" "Terry Gilliam" "Terry Jones" ] ]

View file

@ -0,0 +1,13 @@
[
(builtins.attrNames {})
(builtins.attrNames { foo = 1; bar = 2; baz = 3; })
(builtins.attrNames { Foo = 1; bar = 2; Baz = 3; })
(builtins.attrNames {
"Graham Chapman" = true;
"John Cleese" = true;
"Terry Gilliam" = true;
"Eric Idle" = true;
"Terry Jones" = true;
"Michael Palin" = true;
})
]