Skip to content

Commit d0c0b8a

Browse files
committed
Link between std::env::{var, var_os} and std::env::{vars, vars_os}
1 parent d337cec commit d0c0b8a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

library/std/src/env.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ pub fn vars() -> Vars {
124124
/// variables at the time of this invocation. Modifications to environment
125125
/// variables afterwards will not be reflected in the returned iterator.
126126
///
127+
/// Note that the returned iterator will not check if the environment variables
128+
/// are valid Unicode. If you want to panic on invalid UTF-8,
129+
/// use the [`vars`] function instead.
130+
///
127131
/// # Examples
128132
///
129133
/// ```
@@ -180,8 +184,9 @@ impl fmt::Debug for VarsOs {
180184
///
181185
/// # Errors
182186
///
183-
/// * Environment variable is not present
184-
/// * Environment variable is not valid unicode
187+
/// Errors if the environment variable is not present.
188+
/// Errors if the environment variable is not valid Unicode. If this is not desired, consider using
189+
/// [`var_os`].
185190
///
186191
/// # Panics
187192
///
@@ -221,6 +226,10 @@ fn _var(key: &OsStr) -> Result<String, VarError> {
221226
/// `'='` or the NUL character `'\0'`, or when the value contains the NUL
222227
/// character.
223228
///
229+
/// Note that the method will not check if the environment variable
230+
/// is valid Unicode. If you want to have an error on invalid UTF-8,
231+
/// use the [`var`] function instead.
232+
///
224233
/// # Examples
225234
///
226235
/// ```

0 commit comments

Comments
 (0)