Function envmnt::is_or

source · []
pub fn is_or<K: AsRef<OsStr>>(key: K, default_value: bool) -> bool
Expand description

Returns false if environment variable value if falsy.
Any other value is returned as true.
The value is falsy if it is one of the following:

  • Empty string
  • “false” (case insensitive)
  • “no” (case insensitive)
  • “0”

Arguments

  • key - The environment variable name
  • default_value - In case the environment variable is not defined, this value will be returned.

Example

fn main() {
    envmnt::set_bool("FLAG_VAR", true);
    assert!(envmnt::is_equal("FLAG_VAR", "true"));

    let flag_value = envmnt::is_or("FLAG_VAR", false);
    assert!(flag_value);
}