feat(tvix/eval): add NixContext::extend
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>
This commit is contained in:
parent
48e045299d
commit
a4a313cdd2
1 changed files with 9 additions and 1 deletions
|
@ -87,11 +87,19 @@ impl NixContext {
|
||||||
Self(set)
|
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
|
/// Copies from another [NixString] its context strings
|
||||||
/// in this context.
|
/// in this context.
|
||||||
pub fn mimic(&mut self, other: &NixString) {
|
pub fn mimic(&mut self, other: &NixString) {
|
||||||
if let Some(context) = other.context() {
|
if let Some(context) = other.context() {
|
||||||
self.0.extend(context.iter().cloned());
|
self.extend(context.iter().cloned());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue