Skip to content

Commit 332ab61

Browse files
authored
Rollup merge of rust-lang#128902 - evanj:evan.jones/env-var-doc, r=workingjubilee
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.
2 parents 5044b20 + b0023f5 commit 332ab61

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

library/std/src/env.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,12 @@ impl fmt::Debug for VarsOs {
198198
///
199199
/// # Errors
200200
///
201-
/// This function will return an error if the environment variable isn't set.
201+
/// Returns [`VarError::NotPresent`] if:
202+
/// - The variable is not set.
203+
/// - The variable's name contains an equal sign or NUL (`'='` or `'\0'`).
202204
///
203-
/// This function may return an error if the environment variable's name contains
204-
/// the equal sign character (`=`) or the NUL character.
205-
///
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`].
205+
/// Returns [`VarError::NotUnicode`] if the variable's value is not valid
206+
/// Unicode. If this is not desired, consider using [`var_os`].
208207
///
209208
/// # Examples
210209
///

0 commit comments

Comments
 (0)