Delete variable with given name
(name: String, global: bool)
| 32 | |
| 33 | /// Delete variable with given name |
| 34 | pub 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)] |
| 46 | mod tests { |
no outgoing calls