Skip to content

Commit c252f0d

Browse files
add situation where var_os returns None
Re-introduced some of the former errors as situations where `None` is returned.
1 parent 9f1a3a1 commit c252f0d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

library/std/src/env.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,13 @@ fn _var(key: &OsStr) -> Result<String, VarError> {
236236
}
237237

238238
/// Fetches the environment variable `key` from the current process, returning
239-
/// [`None`] if the variable isn't set or there's another error.
239+
/// [`None`] in the following situations:
240+
///
241+
/// - the environment variable isn't set
242+
/// - the environment variable's name contains
243+
/// the equal sign character (`=`) or the NUL character
244+
///
245+
/// If this is not desired, consider using [`var_os`].
240246
///
241247
/// Note that the method will not check if the environment variable
242248
/// is valid Unicode. If you want to have an error on invalid UTF-8,

0 commit comments

Comments
 (0)