pub fn with_vars<K, V, F, R>(kvs: Vec<(K, Option<V>)>, closure: F) -> Rwhere
    K: AsRef<OsStr> + Clone + Eq + Hash,
    V: AsRef<OsStr> + Clone,
    F: Fn() -> R + 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.