Skip to content

Commit b594afb

Browse files
committed
doc: std::env::var: Returns None for names with '=' or NUL byte
The documentation incorrectly stated that std::env::var could return an error for variable names containing '=' or the NUL byte. Copy the correct documentation from var_os. var_os was fixed in Commit 8a7a665, Pull Request rust-lang#109894, which closed Issue rust-lang#109893. This documentation was incorrectly added in commit f2c0f29, which replaced a panic in var_os by returning None, but documented the change as "May error if ...". Reference the specific error values and link to them.
1 parent 899eb03 commit b594afb

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

library/std/src/env.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,16 @@ impl fmt::Debug for VarsOs {
198198
///
199199
/// # Errors
200200
///
201-
/// This function will return an error if the environment variable isn't set.
201+
/// This function returns [`VarError::NotPresent`] if the environment variable
202+
/// isn't set.
202203
///
203-
/// This function may return an error if the environment variable's name contains
204-
/// the equal sign character (`=`) or the NUL character.
204+
/// This function may return [`VarError::NotPresent`] if the
205+
/// environment variable's name contains the equal sign character (`=`) or the
206+
/// NUL character.
205207
///
206-
/// This function will return an error if the environment variable's value is
207-
/// not valid Unicode. If this is not desired, consider using [`var_os`].
208+
/// This function will return [`VarError::NotUnicode`] if the environment
209+
/// variable's value is not valid Unicode. If this is not desired, consider
210+
/// using [`var_os`].
208211
///
209212
/// # Examples
210213
///

0 commit comments

Comments
 (0)