INNER CODE UNIT · Rust
set
hcavarsan/kftray · crates/kftray-commons/src/lib.rs:111
pub fn set(key: &str, value: &str) -> Self {
let _lock = EnvLock::acquire();
let key = key.to_string();
let original_value = std::env::var(&key).ok();
unsafe { std::env::set_var(&key, value) };
EnvVarGuard {
key,
original_value,
_lock,
}
}
pub fn remove(key: &str) -> Self {
let _lock = EnvLock::acquire();
let key = key.to_string();
let original_value = std::env::var(&key).ok();
unsafe { std::env::remove_var(&key) };
EnvVarGuard {