Function powerpack_env::var_os
source · pub fn var_os<K: AsRef<OsStr>>(key: K) -> Option<OsString>
Expand description
Fetches the environment variable key
from the current process.
This function is similar to std::env::var_os(key).ok()
but it also maps an empty string to None
.
None
Returns None
in the following cases:
- if the environment variable is not present.
- if the environment variable is set to an empty string.
Note that the method will not check if the environment variable is valid
Unicode. If you want to return None
on invalid UTF-8, use the var
function instead.