lib/attrsets.nix: add unionOfDisjoint
This commit is contained in:
parent
bf4312de3e
commit
47de66b1a4
1 changed files with 10 additions and 0 deletions
|
@ -622,6 +622,16 @@ rec {
|
|||
dontRecurseIntoAttrs =
|
||||
attrs: attrs // { recurseForDerivations = false; };
|
||||
|
||||
/* `unionOfDisjoint x y` is equal to `x // y // z` where the
|
||||
attrnames in `z` are the intersection of the attrnames in `x` and
|
||||
`y`, and all values `assert` with an error message */
|
||||
unionOfDisjoint = x: y:
|
||||
x // (mapAttrs
|
||||
(name: val:
|
||||
if hasAttr name x
|
||||
then builtins.throw "attribute collision: ${name}"
|
||||
else val) y);
|
||||
|
||||
/*** deprecated stuff ***/
|
||||
|
||||
zipWithNames = zipAttrsWithNames;
|
||||
|
|
Loading…
Reference in a new issue