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

Changed files
+3 -3
lib
nixos
modules
services
networking
strongswan-swanctl
+2 -2
lib/attrsets.nix
···
:::
*/
-
mapAttrs' = f: set: listToAttrs (map (attr: f attr set.${attr}) (attrNames set));
+
mapAttrs' = f: set: listToAttrs (mapAttrsToList f set);
/**
Call a function for each attribute in the given set and return
···
:::
*/
-
mapAttrsToList = f: attrs: map (name: f name attrs.${name}) (attrNames attrs);
+
mapAttrsToList = f: attrs: attrValues (mapAttrs f attrs);
/**
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
···
in
recurse [ ] set;
-
mapAttrs'' = f: set: foldl' (a: b: a // b) { } (map (attr: f attr set.${attr}) (attrNames set));
+
mapAttrs'' = f: set: foldl' (a: b: a // b) { } (mapAttrsToList f set);
# Extract the options from the given set of parameters.
paramsToOptions = ps: mapParamsRecursive (_path: name: param: { ${name} = param.option; }) ps;