Skip to content

Commit

Permalink
Inline manual clearenv implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
hydhknn committed Feb 11, 2020
1 parent 8de67c4 commit ad29976
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/env.rs
@@ -1,4 +1,3 @@
use std::env;
use {Error, Result};

/// Clear the environment of all name-value pairs.
Expand Down Expand Up @@ -37,7 +36,10 @@ pub unsafe fn clearenv() -> Result<()> {
target_os = "emscripten"))] {
ret = libc::clearenv();
} else {
manual_clearenv();
use std::env;
for (name, _) in env::vars_os() {
env::remove_var(name);
}
ret = 0;
}
}
Expand All @@ -48,9 +50,3 @@ pub unsafe fn clearenv() -> Result<()> {
Err(Error::UnsupportedOperation)
}
}

fn manual_clearenv() {
for (name, _) in env::vars_os() {
env::remove_var(name);
}
}

0 comments on commit ad29976

Please sign in to comment.