lib.strings.isConvertibleWithToString: Refactor to reuse isStringLike

This commit is contained in:
Robert Hensing 2022-12-31 00:49:04 +01:00
parent 834f0d660a
commit 23c25d5231

View file

@ -810,10 +810,9 @@ rec {
null, bool, list of similarly coercible values. null, bool, list of similarly coercible values.
*/ */
isConvertibleWithToString = x: isConvertibleWithToString = x:
elem (typeOf x) [ "path" "string" "null" "int" "float" "bool" ] || isStringLike x ||
(isList x && lib.all isConvertibleWithToString x) || elem (typeOf x) [ "null" "int" "float" "bool" ] ||
x ? outPath || (isList x && lib.all isConvertibleWithToString x);
x ? __toString;
/* Check whether a value can be coerced to a string. /* Check whether a value can be coerced to a string.
The value must be a string, path, or attribute set. The value must be a string, path, or attribute set.