Function temp_env::with_vars[][src]

pub fn with_vars<K, V, F>(kvs: Vec<(K, Option<V>)>, closure: F) where
    K: AsRef<OsStr> + Clone + Eq + Hash,
    V: AsRef<OsStr> + Clone,
    F: Fn() + UnwindSafe + RefUnwindSafe
Expand description

Sets environment variables for the duration of the closure.

The previous values are restored when the closure completes or panics, before unwinding the panic.

If a value is set to None, then the environment variable is unset.

If the variable with the same name is set multiple times, the last one wins.