about summary refs log tree commit diff
path: root/tvix/eval/src/value/string.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-10T17·31+0300
committertazjin <tazjin@tvl.su>2022-08-25T11·11+0000
commitfb3d024d75fe4f6760ef616fe8dfd307b7d7b688 (patch)
tree3f86d2c9ed5eac5d7f949424a943249a550c93a3 /tvix/eval/src/value/string.rs
parent322ce36cea732619c50220fc93f0eba51cf2eb8d (diff)
feat(tvix/eval): implement string concatenation r/4472
Change-Id: If61066e59232b2bad42b5cb5f0f2d9b9c416be8b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6137
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src/value/string.rs')
-rw-r--r--tvix/eval/src/value/string.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/tvix/eval/src/value/string.rs b/tvix/eval/src/value/string.rs
index 72f1467657..1b4f349f1a 100644
--- a/tvix/eval/src/value/string.rs
+++ b/tvix/eval/src/value/string.rs
@@ -63,6 +63,12 @@ impl NixString {
             Cow::Owned(s) => Cow::Owned(format!("\"{}\"", s)),
         }
     }
+
+    pub fn concat(&self, other: &Self) -> Self {
+        let mut s = self.as_str().to_owned();
+        s.push_str(other.as_str());
+        NixString::Heap(s)
+    }
 }
 
 fn nix_escape_char(ch: char) -> Option<&'static str> {