From c252f0d4044876509e08be27f82dbf0f33bc5cc2 Mon Sep 17 00:00:00 2001 From: fleetingbytes <7075397+fleetingbytes@users.noreply.github.com> Date: Mon, 3 Apr 2023 16:46:43 +0200 Subject: [PATCH] add situation where var_os returns None Re-introduced some of the former errors as situations where `None` is returned. --- library/std/src/env.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 3fcf96c761b..63338bd5876 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -236,7 +236,13 @@ fn _var(key: &OsStr) -> Result { } /// Fetches the environment variable `key` from the current process, returning -/// [`None`] if the variable isn't set or there's another error. +/// [`None`] in the following situations: +/// +/// - the environment variable isn't set +/// - the environment variable's name contains +/// the equal sign character (`=`) or the NUL character +/// +/// If this is not desired, consider using [`var_os`]. /// /// 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,