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.


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