about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tvix/eval/src/value/mod.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs
index f0cc86eeda..6c0473fa66 100644
--- a/tvix/eval/src/value/mod.rs
+++ b/tvix/eval/src/value/mod.rs
@@ -62,6 +62,16 @@ impl Value {
         }
     }
 
+    pub fn as_attrs(&self) -> EvalResult<&NixAttrs> {
+        match self {
+            Value::Attrs(attrs) => Ok(attrs),
+            other => Err(Error::TypeError {
+                expected: "set",
+                actual: other.type_of(),
+            }),
+        }
+    }
+
     pub fn to_string(self) -> EvalResult<NixString> {
         match self {
             Value::String(s) => Ok(s),