Function dotenvy::var

source ·
pub fn var<K: AsRef<OsStr>>(key: K) -> Result<String>
Expand description

Gets the value for an environment variable.

The value is Ok(s) if the environment variable is present and valid unicode.

Note: this function gets values from any visible environment variable key, regardless of whether a .env file was loaded.

Examples:

let value = dotenvy::var("HOME")?;
println!("{}", value);  // prints `/home/foo`