diff options
author | Robert Hensing <robert@roberthensing.nl> | 2022-12-31 00:42:22 +0100 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2022-12-31 01:33:47 +0100 |
commit | 834f0d660a79e8f08c108237d76fc1b42024289b (patch) | |
tree | 4d2a7a4b46f6757ac649a5ec63a45606baf6ca53 /lib/strings.nix | |
parent | 872a24ebbc8056142f7930cc0f775237c4ca83f7 (diff) |
lib.strings: isMoreCoercibleString -> isConvertibleWithToString
Yes, this function name is inconveniently long, but it is important for the name to explicitly reference the function and not be mistaken for the implicit string conversions, which only happen for a smaller set of values.
Diffstat (limited to 'lib/strings.nix')
-rw-r--r-- | lib/strings.nix | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/strings.nix b/lib/strings.nix index 0130ea37fb1b2..89574bc8367c2 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -798,19 +798,20 @@ rec { in lib.warnIf (!precise) "Imprecise conversion from float to string ${result}" result; - /* Soft-deprecated name for isMoreCoercibleToString */ + /* Soft-deprecated function. While the original implementation is available as + isConvertibleWithToString, consider using isStringLike instead, if suitable. */ isCoercibleToString = lib.warnIf (lib.isInOldestRelease 2305) - "lib.strings.isCoercibleToString is deprecated in favor of either isStringLike or isMoreCoercibleString. Only use the latter if it needs to return true for null, numbers, booleans and list of similarly coercibles." - isMoreCoercibleToString; + "lib.strings.isCoercibleToString is deprecated in favor of either isStringLike or isConvertibleWithToString. Only use the latter if it needs to return true for null, numbers, booleans and list of similarly coercibles." + isConvertibleWithToString; /* Check whether a list or other value can be passed to toString. Many types of value are coercible to string this way, including int, float, null, bool, list of similarly coercible values. */ - isMoreCoercibleToString = x: + isConvertibleWithToString = x: elem (typeOf x) [ "path" "string" "null" "int" "float" "bool" ] || - (isList x && lib.all isMoreCoercibleToString x) || + (isList x && lib.all isConvertibleWithToString x) || x ? outPath || x ? __toString; |