diff options
-rw-r--r-- | tvix/eval/src/value/mod.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index 1210e0f9a7e9..f6583db5ab97 100644 --- a/tvix/eval/src/value/mod.rs +++ b/tvix/eval/src/value/mod.rs @@ -113,6 +113,17 @@ impl Value { } } + pub fn to_closure(self) -> EvalResult<Closure> { + match self { + Value::Closure(c) => Ok(c), + other => Err(ErrorKind::TypeError { + expected: "lambda", + actual: other.type_of(), + } + .into()), + } + } + pub fn is_bool(&self) -> bool { matches!(self, Value::Bool(_)) } |