Loading lib/attrsets.nix +7 −0 Original line number Diff line number Diff line Loading @@ -51,12 +51,19 @@ rec { /* Return if an attribute from nested attribute set exists. **Laws**: 1. ```nix hasAttrByPath [] x == true ``` Example: x = { a = { b = 3; }; } hasAttrByPath ["a" "b"] x => true hasAttrByPath ["z" "z"] x => false hasAttrByPath [] (throw "no need") => true Type: hasAttrByPath :: [String] -> AttrSet -> Bool Loading lib/tests/misc.nix +5 −0 Original line number Diff line number Diff line Loading @@ -697,6 +697,11 @@ runTests { expected = false; }; testHasAttrByPathNonStrict = { expr = hasAttrByPath [] (throw "do not use"); expected = true; }; testLongestValidPathPrefix_empty_empty = { expr = attrsets.longestValidPathPrefix [ ] { }; expected = [ ]; Loading Loading
lib/attrsets.nix +7 −0 Original line number Diff line number Diff line Loading @@ -51,12 +51,19 @@ rec { /* Return if an attribute from nested attribute set exists. **Laws**: 1. ```nix hasAttrByPath [] x == true ``` Example: x = { a = { b = 3; }; } hasAttrByPath ["a" "b"] x => true hasAttrByPath ["z" "z"] x => false hasAttrByPath [] (throw "no need") => true Type: hasAttrByPath :: [String] -> AttrSet -> Bool Loading
lib/tests/misc.nix +5 −0 Original line number Diff line number Diff line Loading @@ -697,6 +697,11 @@ runTests { expected = false; }; testHasAttrByPathNonStrict = { expr = hasAttrByPath [] (throw "do not use"); expected = true; }; testLongestValidPathPrefix_empty_empty = { expr = attrsets.longestValidPathPrefix [ ] { }; expected = [ ]; Loading