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:
parent
83e5f3b0d3
commit
911fb96eca
1 changed files with 10 additions and 0 deletions
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue