pub fn get_remove<K: AsRef<OsStr>>(key: K) -> Option<String>
Expand description

Removes the provided environment variable and returns its previous value (if any).

Arguments

  • key - The environment variable to remove

Example

fn main() {
    envmnt::set("MY_ENV_VAR", "SOME VALUE");
    assert!(envmnt::is_equal("MY_ENV_VAR", "SOME VALUE"));

    let value = envmnt::get_remove("MY_ENV_VAR");
    assert!(!envmnt::exists("MY_ENV_VAR"));
    assert_eq!(value.unwrap(), "SOME VALUE");
}