std/sys/env/
unsupported.rs

1use crate::ffi::{OsStr, OsString};
2use crate::{fmt, io};
3
4pub struct Env(!);
5
6impl Env {
7    // FIXME(https://github.com/rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt.
8    pub fn str_debug(&self) -> impl fmt::Debug + '_ {
9        self.0
10    }
11}
12
13impl fmt::Debug for Env {
14    fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
15        self.0
16    }
17}
18
19impl Iterator for Env {
20    type Item = (OsString, OsString);
21    fn next(&mut self) -> Option<(OsString, OsString)> {
22        self.0
23    }
24}
25
26pub fn env() -> Env {
27    panic!("not supported on this platform")
28}
29
30pub fn getenv(_: &OsStr) -> Option<OsString> {
31    None
32}
33
34pub unsafe fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> {
35    Err(io::const_error!(io::ErrorKind::Unsupported, "cannot set env vars on this platform"))
36}
37
38pub unsafe fn unsetenv(_: &OsStr) -> io::Result<()> {
39    Err(io::const_error!(io::ErrorKind::Unsupported, "cannot unset env vars on this platform"))
40}