about summary refs log tree commit diff
path: root/tvix/eval/src/builtins/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/builtins/mod.rs')
-rw-r--r--tvix/eval/src/builtins/mod.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index a5ca2114e1f7..f6af16f96f9d 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -134,6 +134,12 @@ fn pure_builtins() -> Vec<Builtin> {
         Builtin::new("length", &[true], |args, _| {
             Ok(Value::Integer(args[0].to_list()?.len() as i64))
         }),
+        Builtin::new("hasAttr", &[true, true], |args, _| {
+            let k = args[0].to_str()?;
+            let xs = args[1].to_attrs()?;
+
+            Ok(Value::Bool(xs.contains(k.as_str())))
+        }),
         Builtin::new("head", &[true], |args, _| match args[0].to_list()?.get(0) {
             Some(x) => Ok(x.clone()),
             None => Err(ErrorKind::IndexOutOfBounds { index: 0 }),