MCPcopy Create free account
hub / github.com/ankddev/envfetch / delete_variable

Function delete_variable

src/variables.rs:34–43  ·  view source on GitHub ↗

Delete variable with given name

(name: String, global: bool)

Source from the content-addressed store, hash-verified

32
33/// Delete variable with given name
34pub fn delete_variable(name: String, global: bool) -> Result<(), ErrorKind> {
35 if global {
36 if let Err(err) = globalenv::unset_var(&name) {
37 return Err(ErrorKind::CannotDeleteVariableGlobally(err.to_string()));
38 }
39 } else {
40 unsafe { env::remove_var(&name) };
41 }
42 Ok(())
43}
44
45#[cfg(test)]
46mod tests {

Callers 6

test_delete_variableFunction · 0.85
test_set_variable_globalFunction · 0.85
deleteFunction · 0.85
handle_delete_modeFunction · 0.85

Calls

no outgoing calls

Tested by 4

test_delete_variableFunction · 0.68
test_set_variable_globalFunction · 0.68