-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2664 from rami3l/env-literal
feat(parser): accept boolean literal with env vars
- Loading branch information
Showing
5 changed files
with
97 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/// True values are `y`, `yes`, `t`, `true`, `on`, and `1`. | ||
// pub(crate) const TRUE_LITERALS: [&str; 6] = ["y", "yes", "t", "true", "on", "1"]; | ||
|
||
/// False values are `n`, `no`, `f`, `false`, `off`, and `0`. | ||
const FALSE_LITERALS: [&str; 6] = ["n", "no", "f", "false", "off", "0"]; | ||
|
||
/// Converts a string literal representation of truth to true or false. | ||
/// | ||
/// `false` values are `n`, `no`, `f`, `false`, `off`, and `0` (case insensitive). | ||
/// | ||
/// Any other value will be considered as `true`. | ||
pub(crate) fn str_to_bool(val: impl AsRef<str>) -> bool { | ||
let pat: &str = &val.as_ref().to_lowercase(); | ||
!FALSE_LITERALS.contains(&pat) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters