about summary refs log tree commit diff
path: root/tvix/eval
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-05-23T09·13+0200
committerclbot <clbot@tvl.fyi>2024-05-23T14·49+0000
commita4a313cdd28b30eff54b8455f11df9de32640548 (patch)
tree3bca4fc10c3ebb03fd9f47003e84362849bbd62c /tvix/eval
parent48e045299dd409975e77878e6960fc8c429fece1 (diff)
feat(tvix/eval): add NixContext::extend r/8162
This is a slightly less annoying version of `join`, which does not
consume self. It's more consistent with HashSet::extend().

Change-Id: Ifd0872da36fe8e7b2aa6948674cb8e4023abe9d7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11703
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: edef <edef@edef.eu>
Diffstat (limited to 'tvix/eval')
-rw-r--r--tvix/eval/src/value/string.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/tvix/eval/src/value/string.rs b/tvix/eval/src/value/string.rs
index ceb43f1ea5ed..a418a276f99c 100644
--- a/tvix/eval/src/value/string.rs
+++ b/tvix/eval/src/value/string.rs
@@ -87,11 +87,19 @@ impl NixContext {
         Self(set)
     }
 
+    /// Extends the existing context with more context elements.
+    pub fn extend<T>(&mut self, iter: T)
+    where
+        T: IntoIterator<Item = NixContextElement>,
+    {
+        self.0.extend(iter)
+    }
+
     /// Copies from another [NixString] its context strings
     /// in this context.
     pub fn mimic(&mut self, other: &NixString) {
         if let Some(context) = other.context() {
-            self.0.extend(context.iter().cloned());
+            self.extend(context.iter().cloned());
         }
     }