diff options
author | Vincent Ambo <mail@tazj.in> | 2022-08-26T23·07+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-09-03T21·55+0000 |
commit | 5ecf573dffc581e7842263f674ef43a66a2ba900 (patch) | |
tree | 07f6a5417236acef788ca85d357353e259877957 /tvix | |
parent | 69d8f17a26db50e7b76297dbf588aafc23425c71 (diff) |
feat(tvix/eval): add Value::to_closure r/4626
... same as the others Change-Id: I9c8868388c10b0b6484c5bdd3799d801296c6979 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6292 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'tvix')
-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(_)) } |