From 911fb96eca84a3059ecc11af9c3ac6fdacc28166 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 15 Aug 2022 01:13:02 +0300 Subject: 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 Reviewed-by: grfn --- tvix/eval/src/value/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tvix/eval/src/value/mod.rs') 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 { match self { Value::String(s) => Ok(s), -- cgit 1.4.1