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 <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2022-08-27 02:07:37 +03:00 committed by tazjin
parent 69d8f17a26
commit 5ecf573dff

View file

@ -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(_))
}