From 5ecf573dffc581e7842263f674ef43a66a2ba900 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 27 Aug 2022 02:07:37 +0300 Subject: feat(tvix/eval): add Value::to_closure ... same as the others Change-Id: I9c8868388c10b0b6484c5bdd3799d801296c6979 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6292 Tested-by: BuildkiteCI Reviewed-by: grfn --- tvix/eval/src/value/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 { + 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(_)) } -- cgit 1.4.1