mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03:00
lib.strings: Add isSimpleCoercibleToString
This commit is contained in:
parent
393bdd70e2
commit
67cfc7a8f6
1 changed files with 11 additions and 0 deletions
|
@ -805,6 +805,17 @@ rec {
|
||||||
x ? outPath ||
|
x ? outPath ||
|
||||||
x ? __toString;
|
x ? __toString;
|
||||||
|
|
||||||
|
/* Check whether a value can be coerced to a string,
|
||||||
|
The value must be a string, path, or attribute set.
|
||||||
|
|
||||||
|
This follows Nix's internal coerceToString(coerceMore = false) logic,
|
||||||
|
except for external types, for which we return false.
|
||||||
|
*/
|
||||||
|
isSimpleCoercibleToString = x:
|
||||||
|
elem (typeOf x) [ "path" "string" ] ||
|
||||||
|
x ? outPath ||
|
||||||
|
x ? __toString;
|
||||||
|
|
||||||
/* Check whether a value is a store path.
|
/* Check whether a value is a store path.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue