diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-04-27 10:56:51 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-04-28 21:44:21 +0000 |
commit | 81e1e68eaf6c765147da964d356f704030734dd2 (patch) | |
tree | 122c02c4d7e0b8e927cf82049481d35ea0137196 /lib/strings.nix | |
parent | e57815f09595689b9d09c1ba4585ec4c8b8e5e5a (diff) | |
download | nixpkgs-81e1e68eaf6c765147da964d356f704030734dd2.tar nixpkgs-81e1e68eaf6c765147da964d356f704030734dd2.tar.gz nixpkgs-81e1e68eaf6c765147da964d356f704030734dd2.tar.bz2 nixpkgs-81e1e68eaf6c765147da964d356f704030734dd2.tar.lz nixpkgs-81e1e68eaf6c765147da964d356f704030734dd2.tar.xz nixpkgs-81e1e68eaf6c765147da964d356f704030734dd2.tar.zst nixpkgs-81e1e68eaf6c765147da964d356f704030734dd2.zip |
lib.trivial.warnIf: init
It's a common pattern in Nixpkgs to want to emit a warning in certain cases, but not actually change behaviours. This is often expressed as either if cond then lib.warn "Don't do that thing" x else x Or (if cond then lib.warn "Don't do that thing" else lib.id) x Neither of which really expresses the intent here, because it looks like 'x' is being chosen conditionally. To make this clearer, I introduce a "warnIf" function, which makes it clear that the only thing being affected by the condition is whether the warning is generated, not the value being returned.
Diffstat (limited to 'lib/strings.nix')
0 files changed, 0 insertions, 0 deletions