feat(tvix/eval): Support builtins.attrValues
:) Change-Id: Idf170b506ed6fab035b1e6f61055fee02e5c9be8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6547 Reviewed-by: wpcarro <wpcarro@gmail.com> Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: wpcarro <wpcarro@gmail.com> Tested-by: BuildkiteCI
This commit is contained in:
parent
067f2b16f6
commit
5a6d9ee1a0
3 changed files with 17 additions and 0 deletions
|
@ -89,6 +89,18 @@ fn pure_builtins() -> Vec<Builtin> {
|
|||
Ok(Value::List(NixList::construct(output.len(), output)))
|
||||
})
|
||||
}),
|
||||
Builtin::new("attrValues", 1, |args, vm| {
|
||||
force!(vm, &args[0], value, {
|
||||
let xs = value.to_attrs()?;
|
||||
let mut output = Vec::with_capacity(xs.len());
|
||||
|
||||
for (_key, val) in xs.iter() {
|
||||
output.push(val.clone());
|
||||
}
|
||||
|
||||
Ok(Value::List(NixList::construct(output.len(), output)))
|
||||
})
|
||||
}),
|
||||
Builtin::new("catAttrs", 2, |mut args, _| {
|
||||
let list = args.pop().unwrap().to_list()?;
|
||||
let key = args.pop().unwrap().to_str()?;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[ [ ] [ 2 3 1 ] ]
|
|
@ -0,0 +1,4 @@
|
|||
[
|
||||
(builtins.attrValues {})
|
||||
(builtins.attrValues { foo = 1; bar = 2; baz = 3; })
|
||||
]
|
Loading…
Reference in a new issue