diff options
author | Silvan Mosberger <contact@infinisil.com> | 2023-12-11 17:46:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-11 17:46:48 +0100 |
commit | 04efefaa4c0ee3ff165b634d57625164c85f250a (patch) | |
tree | e978d6843e80da7ae9aa44ad8ca645d1e21b1c01 /lib | |
parent | 6d8c22272a2aef9fd0e74f833c8ee94d37f75a5d (diff) | |
parent | a128a3f234afb3d0a1d67b8b36e93cc629d0186d (diff) | |
download | nixlib-04efefaa4c0ee3ff165b634d57625164c85f250a.tar nixlib-04efefaa4c0ee3ff165b634d57625164c85f250a.tar.gz nixlib-04efefaa4c0ee3ff165b634d57625164c85f250a.tar.bz2 nixlib-04efefaa4c0ee3ff165b634d57625164c85f250a.tar.lz nixlib-04efefaa4c0ee3ff165b634d57625164c85f250a.tar.xz nixlib-04efefaa4c0ee3ff165b634d57625164c85f250a.tar.zst nixlib-04efefaa4c0ee3ff165b634d57625164c85f250a.zip |
Merge pull request #273473 from adisbladis/lib-isConvertibleToString-static-list
lib.isConvertibleToString: Statically compute types list
Diffstat (limited to 'lib')
-rw-r--r-- | lib/strings.nix | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/strings.nix b/lib/strings.nix index 93247cfcf35e..49654d8abaa7 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -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. |