diff options
| author | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2025-01-20 21:45:04 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-20 21:45:04 +0800 |
| commit | e7f53663de0073dc6c16b744f984638265e7f5fb (patch) | |
| tree | f62e09de3d32452dd69b081e60a920af780f33c9 | |
| parent | bdd88ddd309077ef2356c226f93f3fe9608eb494 (diff) | |
| parent | f7c2d1194d31f34238765afb2d5dee583e2a3cfc (diff) | |
| download | rust-e7f53663de0073dc6c16b744f984638265e7f5fb.tar.gz rust-e7f53663de0073dc6c16b744f984638265e7f5fb.zip | |
Rollup merge of #135626 - clubby789:env-note, r=ibraheemdev
doc: Point to methods on `Command` as alternatives to `set/remove_var` Make these methods more discoverable, as configuring a child process is a common reason for manipulating the environment.
| -rw-r--r-- | library/std/src/env.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 11a29cdae62..bbd506127fb 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -336,7 +336,10 @@ impl Error for VarError { /// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188) /// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2) /// +/// To pass an environment variable to a child process, you can instead use [`Command::env`]. +/// /// [`std::net::ToSocketAddrs`]: crate::net::ToSocketAddrs +/// [`Command::env`]: crate::process::Command::env /// /// # Panics /// @@ -396,7 +399,12 @@ pub unsafe fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(key: K, value: V) { /// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188) /// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2) /// +/// To prevent a child process from inheriting an environment variable, you can +/// instead use [`Command::env_remove`] or [`Command::env_clear`]. +/// /// [`std::net::ToSocketAddrs`]: crate::net::ToSocketAddrs +/// [`Command::env_remove`]: crate::process::Command::env_remove +/// [`Command::env_clear`]: crate::process::Command::env_clear /// /// # Panics /// |
