Function envmnt::is

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

Returns false if environment variable value if falsy. The value is falsy if it is one of the following:

  • Empty string
  • “false” (case insensitive)
  • “no” (case insensitive)
  • “0”
    Any other value is returned as true. This is same as calling is_or(“varname”, false)

Arguments

  • key - The environment variable name

Example

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

    let flag_value = envmnt::is("FLAG_VAR");
    assert!(flag_value);
}