std::env::set_var safely
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index ce09c3a..5eb2715 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -43,6 +43,7 @@ const SAFE: bool = matches!(
/// ```
#[must_use = "this function may not always run"]
pub fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(key: K, value: V) -> Option<()> {
+ // SAFETY: this function is safe to call in single threaded environments or on good OS's.
(SAFE || num_threads::is_single_threaded() == Some(true))
.then(|| unsafe { std::env::set_var(key, value) })
}