Function temp_env::with_var

source ·
pub fn with_var<K, V, F, R>(key: K, value: Option<V>, closure: F) -> Rwhere
    K: AsRef<OsStr> + Clone + Eq + Hash,
    V: AsRef<OsStr> + Clone,
    F: Fn() -> R,
Expand description

Sets a single environment variable for the duration of the closure.

The previous value is restored when the closure completes or panics, before unwinding the panic.

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