1.0.0[][src]Function sors::var

pub fn var<K>(key: K) -> Result<String, VarError> where
    K: AsRef<OsStr>, 

Fetches the environment variable key from the current process.

Errors

  • Environment variable is not present
  • Environment variable is not valid unicode

Examples

use std::env;

let key = "HOME";
match env::var(key) {
    Ok(val) => println!("{}: {:?}", key, val),
    Err(e) => println!("couldn't interpret {}: {}", key, e),
}