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/list.rs19
-rw-r--r--tvix/eval/src/value/mod.rs7
2 files changed, 13 insertions, 13 deletions
diff --git a/tvix/eval/src/value/list.rs b/tvix/eval/src/value/list.rs
index 0a7ff8a58a79..0ab180a341e9 100644
--- a/tvix/eval/src/value/list.rs
+++ b/tvix/eval/src/value/list.rs
@@ -27,14 +27,6 @@ impl TotalDisplay for NixList {
     }
 }
 
-// TODO(tazjin): uses of this instance are likely inefficient and can be optimised.
-// Eventually this instance should be removed.
-impl From<Vec<Value>> for NixList {
-    fn from(vs: Vec<Value>) -> Self {
-        Self(Vector::from_iter(vs.into_iter()))
-    }
-}
-
 impl From<Vector<Value>> for NixList {
     fn from(vs: Vector<Value>) -> Self {
         Self(vs)
@@ -57,7 +49,9 @@ mod arbitrary {
         type Strategy = BoxedStrategy<Self>;
 
         fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
-            any_with::<Vec<Value>>(args).prop_map(|v| v.into()).boxed()
+            any_with::<Vec<Value>>(args)
+                .prop_map(NixList::from_vec)
+                .boxed()
         }
     }
 }
@@ -79,7 +73,7 @@ impl NixList {
             stack_slice.len(),
         );
 
-        stack_slice.into()
+        NixList(Vector::from_iter(stack_slice.into_iter()))
     }
 
     pub fn iter(&self) -> vector::Iter<Value> {
@@ -116,6 +110,11 @@ impl NixList {
     pub fn into_inner(self) -> Vector<Value> {
         self.0
     }
+
+    #[deprecated(note = "callers should avoid constructing from Vec")]
+    pub fn from_vec(vs: Vec<Value>) -> Self {
+        Self(Vector::from_iter(vs.into_iter()))
+    }
 }
 
 impl IntoIterator for NixList {
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs
index 34dbf06231d4..1c6d104bd864 100644
--- a/tvix/eval/src/value/mod.rs
+++ b/tvix/eval/src/value/mod.rs
@@ -544,7 +544,7 @@ impl From<PathBuf> for Value {
 
 impl From<Vec<Value>> for Value {
     fn from(val: Vec<Value>) -> Self {
-        Self::List(NixList::from(val))
+        Self::List(NixList::from_vec(val))
     }
 }
 
@@ -601,6 +601,7 @@ fn type_error(expected: &'static str, actual: &Value) -> ErrorKind {
 #[cfg(test)]
 mod tests {
     use super::*;
+    use im::vector;
 
     mod nix_eq {
         use crate::observer::NoOpObserver;
@@ -643,8 +644,8 @@ mod tests {
             let mut observer = NoOpObserver {};
             let mut vm = VM::new(Default::default(), Box::new(crate::DummyIO), &mut observer);
 
-            let v1 = Value::List(NixList::from(vec![Value::Integer(1)]));
-            let v2 = Value::List(NixList::from(vec![Value::Float(1.0)]));
+            let v1 = Value::List(NixList::from(vector![Value::Integer(1)]));
+            let v2 = Value::List(NixList::from(vector![Value::Float(1.0)]));
 
             assert!(v1.nix_eq(&v2, &mut vm).unwrap())
         }