Skip to content

Commit 2500719

Browse files
committed
Add note about safety of std::env::set_var on Windows
1 parent c4b1ff8 commit 2500719

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

std/src/env.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,14 @@ impl Error for VarError {
320320
///
321321
/// This function is safe to call in a single-threaded program.
322322
///
323-
/// In multi-threaded programs, you must ensure that are no other threads
324-
/// concurrently writing or *reading*(!) from the environment through functions
325-
/// other than the ones in this module. You are responsible for figuring out
326-
/// how to achieve this, but we strongly suggest not using `set_var` or
327-
/// `remove_var` in multi-threaded programs at all.
323+
/// This function is also always safe to call on Windows, in single-threaded
324+
/// and multi-threaded programs.
325+
///
326+
/// In multi-threaded programs on other operating systems, you must ensure that
327+
/// are no other threads concurrently writing or *reading*(!) from the
328+
/// environment through functions other than the ones in this module. You are
329+
/// responsible for figuring out how to achieve this, but we strongly suggest
330+
/// not using `set_var` or `remove_var` in multi-threaded programs at all.
328331
///
329332
/// Most C libraries, including libc itself, do not advertise which functions
330333
/// read from the environment. Even functions from the Rust standard library do
@@ -379,6 +382,9 @@ unsafe fn _set_var(key: &OsStr, value: &OsStr) {
379382
///
380383
/// This function is safe to call in a single-threaded program.
381384
///
385+
/// This function is also always safe to call on Windows, in single-threaded
386+
/// and multi-threaded programs.
387+
///
382388
/// In multi-threaded programs, you must ensure that are no other threads
383389
/// concurrently writing or *reading*(!) from the environment through functions
384390
/// other than the ones in this module. You are responsible for figuring out

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy