Function temp_env::with_var_unset [−][src]
pub fn with_var_unset<K, F>(key: K, closure: F) where
K: AsRef<OsStr> + Clone + Eq + Hash,
F: Fn() + UnwindSafe + RefUnwindSafe,
Expand description
Unsets 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.
This is a shorthand and identical to the following:
temp_env::with_var("MY_ENV_VAR", None::<&str>, || {
// Run some code where `MY_ENV_VAR` is unset.
});