diff options
author | Vincent Ambo <mail@tazj.in> | 2022-08-14T22·13+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-08-31T22·26+0000 |
commit | 911fb96eca84a3059ecc11af9c3ac6fdacc28166 (patch) | |
tree | 78ac0f0206ffb91d0a695868db9273c9b94b597e /tvix/eval/src | |
parent | 83e5f3b0d319c7f4d1f0bb85c39bbfe383d04637 (diff) |
feat(tvix/eval): add Value::as_attrs method r/4555
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>
Diffstat (limited to 'tvix/eval/src')
-rw-r--r-- | tvix/eval/src/value/mod.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index f0cc86eedac4..6c0473fa6618 100644 --- a/tvix/eval/src/value/mod.rs +++ b/tvix/eval/src/value/mod.rs @@ -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), |