Merge pull request #273473 from adisbladis/lib-isConvertibleToString-static-list

lib.isConvertibleToString: Statically compute types list
This commit is contained in:
Silvan Mosberger 2023-12-11 17:46:48 +01:00 committed by GitHub
commit 04efefaa4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -978,9 +978,11 @@ rec {
Many types of value are coercible to string this way, including int, float,
null, bool, list of similarly coercible values.
*/
isConvertibleWithToString = x:
isConvertibleWithToString = let
types = [ "null" "int" "float" "bool" ];
in x:
isStringLike x ||
elem (typeOf x) [ "null" "int" "float" "bool" ] ||
elem (typeOf x) types ||
(isList x && lib.all isConvertibleWithToString x);
/* Check whether a value can be coerced to a string.