From fb3d024d75fe4f6760ef616fe8dfd307b7d7b688 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 10 Aug 2022 20:31:35 +0300 Subject: feat(tvix/eval): implement string concatenation Change-Id: If61066e59232b2bad42b5cb5f0f2d9b9c416be8b Reviewed-on: https://cl.tvl.fyi/c/depot/+/6137 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/value/string.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tvix/eval/src/value/string.rs') 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> { -- cgit 1.4.1