diff options
Diffstat (limited to 'tvix/eval/src/value')
-rw-r--r-- | tvix/eval/src/value/mod.rs | 2 | ||||
-rw-r--r-- | tvix/eval/src/value/string.rs | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index f8fb9c7b40b7..47096dd40912 100644 --- a/tvix/eval/src/value/mod.rs +++ b/tvix/eval/src/value/mod.rs @@ -101,6 +101,8 @@ impl Value { kind: CoercionKind, vm: &mut VM, ) -> Result<NixString, ErrorKind> { + // TODO: eventually, this will need to handle string context and importing + // files into the Nix store depending on what context the coercion happens in if let Value::Thunk(t) = self { t.force(vm)?; } 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> { |