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/mod.rs6
-rw-r--r--tvix/eval/src/value/string.rs15
2 files changed, 21 insertions, 0 deletions
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs
index 0f3b9cbbf4a2..0e9d013fdf61 100644
--- a/tvix/eval/src/value/mod.rs
+++ b/tvix/eval/src/value/mod.rs
@@ -377,6 +377,12 @@ impl From<&str> for Value {
     }
 }
 
+impl From<String> for Value {
+    fn from(val: String) -> Self {
+        Self::String(val.into())
+    }
+}
+
 fn type_error(expected: &'static str, actual: &Value) -> ErrorKind {
     ErrorKind::TypeError {
         expected,
diff --git a/tvix/eval/src/value/string.rs b/tvix/eval/src/value/string.rs
index bfbaa815db99..c21f2c4e8395 100644
--- a/tvix/eval/src/value/string.rs
+++ b/tvix/eval/src/value/string.rs
@@ -2,6 +2,7 @@
 //! backing implementations.
 use smol_str::SmolStr;
 use std::hash::Hash;
+use std::ops::Deref;
 use std::{borrow::Cow, fmt::Display, str::Chars};
 
 #[derive(Clone, Debug)]
@@ -178,6 +179,20 @@ impl Display for NixString {
     }
 }
 
+impl AsRef<str> for NixString {
+    fn as_ref(&self) -> &str {
+        self.as_str()
+    }
+}
+
+impl Deref for NixString {
+    type Target = str;
+
+    fn deref(&self) -> &Self::Target {
+        self.as_str()
+    }
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;