about summary refs log tree commit diff
path: root/tvix/eval/src/value
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/value')
-rw-r--r--tvix/eval/src/value/arbitrary.rs4
-rw-r--r--tvix/eval/src/value/mod.rs8
2 files changed, 10 insertions, 2 deletions
diff --git a/tvix/eval/src/value/arbitrary.rs b/tvix/eval/src/value/arbitrary.rs
index 20be3732e007..cd7629cfb923 100644
--- a/tvix/eval/src/value/arbitrary.rs
+++ b/tvix/eval/src/value/arbitrary.rs
@@ -1,7 +1,7 @@
 //! Support for configurable generation of arbitrary nix values
 
 use proptest::{prelude::*, strategy::BoxedStrategy};
-use std::{ffi::OsString, rc::Rc};
+use std::ffi::OsString;
 
 use super::{NixAttrs, NixList, NixString, Value};
 
@@ -70,7 +70,7 @@ fn non_internal_value() -> impl Strategy<Value = Value> {
                 Default::default(),
                 Parameters::Strategy(inner.clone())
             ))
-            .prop_map(|a| Value::Attrs(Rc::new(a))),
+            .prop_map(Value::attrs),
             any_with::<NixList>((Default::default(), Parameters::Strategy(inner)))
                 .prop_map(Value::List)
         ]
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs
index e6a6052c21dd..dd61ecf0bbea 100644
--- a/tvix/eval/src/value/mod.rs
+++ b/tvix/eval/src/value/mod.rs
@@ -115,6 +115,14 @@ impl<'a> Deref for ForceResult<'a> {
     }
 }
 
+/// Constructors
+impl Value {
+    /// Construct a [`Value::Attrs`] from a [`NixAttrs`].
+    pub fn attrs(attrs: NixAttrs) -> Self {
+        Self::Attrs(Rc::new(attrs))
+    }
+}
+
 impl Value {
     /// Coerce a `Value` to a string. See `CoercionKind` for a rundown of what
     /// input types are accepted under what circumstances.