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:
parent
69d8f17a26
commit
5ecf573dff
1 changed files with 11 additions and 0 deletions
|
@ -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 {
|
pub fn is_bool(&self) -> bool {
|
||||||
matches!(self, Value::Bool(_))
|
matches!(self, Value::Bool(_))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue