Function temp_env::with_vars_unset [−][src]
pub fn with_vars_unset<K, F>(keys: Vec<K>, closure: F) where
K: AsRef<OsStr> + Clone + Eq + Hash,
F: Fn() + UnwindSafe + RefUnwindSafe,
Expand description
Unsets environment variables for the duration of the closure.
The previous values are restored when the closure completes or panics, before unwinding the panic.
This is a shorthand and identical to the following:
temp_env::with_vars(
vec![
("FIRST_VAR", None::<&str>),
("SECOND_VAR", None::<&str>),
],
|| {
// Run some code where `FIRST_VAR` and `SECOND_VAR` are unset (even if
// they were set before)
}
);