about summary refs log tree commit diff
path: root/tvix/eval/src/value/string.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/value/string.rs')
-rw-r--r--tvix/eval/src/value/string.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/tvix/eval/src/value/string.rs b/tvix/eval/src/value/string.rs
index aa542181f9b1..058c7f87dda8 100644
--- a/tvix/eval/src/value/string.rs
+++ b/tvix/eval/src/value/string.rs
@@ -2,7 +2,7 @@
 //! backing implementations.
 use smol_str::SmolStr;
 use std::hash::Hash;
-use std::{borrow::Cow, fmt::Display};
+use std::{borrow::Cow, fmt::Display, str::Chars};
 
 #[derive(Clone, Debug)]
 enum StringRepr {
@@ -97,6 +97,13 @@ impl NixString {
         s.push_str(other.as_str());
         NixString(StringRepr::Heap(s))
     }
+
+    pub fn chars(&self) -> Chars<'_> {
+        match &self.0 {
+            StringRepr::Heap(h) => h.chars(),
+            StringRepr::Smol(s) => s.chars(),
+        }
+    }
 }
 
 fn nix_escape_char(ch: char, next: Option<&char>) -> Option<&'static str> {