about summary refs log tree commit diff
path: root/library/std/src/env.rs
diff options
context:
space:
mode:
authorTobias Bucher <tobiasbucher5991@gmail.com>2024-05-24 10:04:44 +0200
committerTobias Bucher <tobiasbucher5991@gmail.com>2024-05-29 23:42:27 +0200
commit8cf49806486133a1fae72ca22c732ed2800eb879 (patch)
tree917b36ab741f66a1951321feaa02d6a776153512 /library/std/src/env.rs
parent5d8f9b4dc1c913e62387e10762f018f182a34582 (diff)
downloadrust-8cf49806486133a1fae72ca22c732ed2800eb879.tar.gz
rust-8cf49806486133a1fae72ca22c732ed2800eb879.zip
Add note about safety of `std::env::set_var` on Windows
Diffstat (limited to 'library/std/src/env.rs')
-rw-r--r--library/std/src/env.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/library/std/src/env.rs b/library/std/src/env.rs
index 95ee2a91d15..d433caa9d2a 100644
--- a/library/std/src/env.rs
+++ b/library/std/src/env.rs
@@ -320,11 +320,14 @@ impl Error for VarError {
 ///
 /// This function is safe to call in a single-threaded program.
 ///
-/// In multi-threaded programs, you must ensure that are no other threads
-/// concurrently writing or *reading*(!) from the environment through functions
-/// other than the ones in this module. You are responsible for figuring out
-/// how to achieve this, but we strongly suggest not using `set_var` or
-/// `remove_var` in multi-threaded programs at all.
+/// This function is also always safe to call on Windows, in single-threaded
+/// and multi-threaded programs.
+///
+/// In multi-threaded programs on other operating systems, you must ensure that
+/// are no other threads concurrently writing or *reading*(!) from the
+/// environment through functions other than the ones in this module. You are
+/// responsible for figuring out how to achieve this, but we strongly suggest
+/// not using `set_var` or `remove_var` in multi-threaded programs at all.
 ///
 /// Most C libraries, including libc itself, do not advertise which functions
 /// read from the environment. Even functions from the Rust standard library do
@@ -379,6 +382,9 @@ unsafe fn _set_var(key: &OsStr, value: &OsStr) {
 ///
 /// This function is safe to call in a single-threaded program.
 ///
+/// This function is also always safe to call on Windows, in single-threaded
+/// and multi-threaded programs.
+///
 /// In multi-threaded programs, you must ensure that are no other threads
 /// concurrently writing or *reading*(!) from the environment through functions
 /// other than the ones in this module. You are responsible for figuring out