lib: refactor lib.attrsets.{mapAttrs', mapAttrsToList} and mapAttrs'' in the strongswan-swanctl module (#403581)

authored by Johannes Kirschbauer and committed by GitHub 5ee93d25 da51ddbc

+3 -3
+2 -2
lib/attrsets.nix
··· 1042 1042 1043 1043 ::: 1044 1044 */ 1045 - mapAttrs' = f: set: listToAttrs (map (attr: f attr set.${attr}) (attrNames set)); 1045 + mapAttrs' = f: set: listToAttrs (mapAttrsToList f set); 1046 1046 1047 1047 /** 1048 1048 Call a function for each attribute in the given set and return ··· 1076 1076 1077 1077 ::: 1078 1078 */ 1079 - mapAttrsToList = f: attrs: map (name: f name attrs.${name}) (attrNames attrs); 1079 + mapAttrsToList = f: attrs: attrValues (mapAttrs f attrs); 1080 1080 1081 1081 /** 1082 1082 Deconstruct an attrset to a list of name-value pairs as expected by [`builtins.listToAttrs`](https://nixos.org/manual/nix/stable/language/builtins.html#builtins-listToAttrs).
+1 -1
nixos/modules/services/networking/strongswan-swanctl/param-lib.nix
··· 89 89 in 90 90 recurse [ ] set; 91 91 92 - mapAttrs'' = f: set: foldl' (a: b: a // b) { } (map (attr: f attr set.${attr}) (attrNames set)); 92 + mapAttrs'' = f: set: foldl' (a: b: a // b) { } (mapAttrsToList f set); 93 93 94 94 # Extract the options from the given set of parameters. 95 95 paramsToOptions = ps: mapParamsRecursive (_path: name: param: { ${name} = param.option; }) ps;