feat(tvix/eval): add Value::as_attrs method

Change-Id: I2f39122ac85b67837335aab308d845907160e132
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6221
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2022-08-15 01:13:02 +03:00 committed by tazjin
parent 83e5f3b0d3
commit 911fb96eca

View file

@ -62,6 +62,16 @@ impl Value {
}
}
pub fn as_attrs(&self) -> EvalResult<&NixAttrs> {
match self {
Value::Attrs(attrs) => Ok(attrs),
other => Err(Error::TypeError {
expected: "set",
actual: other.type_of(),
}),
}
}
pub fn to_string(self) -> EvalResult<NixString> {
match self {
Value::String(s) => Ok(s),