about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJack Huey <31162821+jackh726@users.noreply.github.com>2021-04-29 19:27:25 -0400
committerGitHub <noreply@github.com>2021-04-29 19:27:25 -0400
commit6e50ac8a3449af9b2d59cd7964ff0eb8cb003807 (patch)
treee7ce1263f25951e7a25dc9516639238ec7d77a14
parent8460539f28538331bfc40139a9ceaa648e979b47 (diff)
parentd0c0b8a4a37827da956aafff33fa9882a3bc0df9 (diff)
downloadrust-6e50ac8a3449af9b2d59cd7964ff0eb8cb003807.tar.gz
rust-6e50ac8a3449af9b2d59cd7964ff0eb8cb003807.zip
Rollup merge of #84692 - r00ster91:var-var_os-vars, r=joshtriplett
Link between std::env::{var, var_os} and std::env::{vars, vars_os}

In #84551 I linked between `std::env::{args, args_os}` and this PR does the same but for `std::env::{var, var_os}` and `std::env::{vars, vars_os}`. Now all of `std::env::{var, var_os, vars, vars_os, args, args_os}` should each mention their `_os` or non-`_os` equivalent in the docs so that you can easily navigate between them.
-rw-r--r--library/std/src/env.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/library/std/src/env.rs b/library/std/src/env.rs
index d20bb585841..821e7d4cfe7 100644
--- a/library/std/src/env.rs
+++ b/library/std/src/env.rs
@@ -124,6 +124,10 @@ pub fn vars() -> Vars {
 /// variables at the time of this invocation. Modifications to environment
 /// variables afterwards will not be reflected in the returned iterator.
 ///
+/// Note that the returned iterator will not check if the environment variables
+/// are valid Unicode. If you want to panic on invalid UTF-8,
+/// use the [`vars`] function instead.
+///
 /// # Examples
 ///
 /// ```
@@ -180,8 +184,9 @@ impl fmt::Debug for VarsOs {
 ///
 /// # Errors
 ///
-/// * Environment variable is not present
-/// * Environment variable is not valid unicode
+/// Errors if the environment variable is not present.
+/// Errors if the environment variable is not valid Unicode. If this is not desired, consider using
+/// [`var_os`].
 ///
 /// # Panics
 ///
@@ -221,6 +226,10 @@ fn _var(key: &OsStr) -> Result<String, VarError> {
 /// `'='` or the NUL character `'\0'`, or when the value contains the NUL
 /// character.
 ///
+/// Note that the method will not check if the environment variable
+/// is valid Unicode. If you want to have an error on invalid UTF-8,
+/// use the [`var`] function instead.
+///
 /// # Examples
 ///
 /// ```