pub fn env_parse_bool(env: &str) -> Result<Option<bool>>Expand description
Parse an environment variable as a boolean, returning an error if invalid.
§Arguments
env- The environment variable name
§Returns
Ok(Some(true))- If the env var is set to a truthy valueOk(Some(false))- If the env var is set to a falsey valueOk(None)- If the env var is not setErr(_)- If the env var is set to an invalid value
§Example
ⓘ
match env_parse_bool("MY_FLAG")? {
Some(true) => println!("enabled"),
Some(false) => println!("disabled"),
None => println!("not configured"),
}