Although `Env` (as `Vars`), `Args`, path functions, and OS constants are publicly exposed via `std::env`, their implementations are each self-contained. Keep them separate in `std::sys` and make a new module, `sys::env`, for `Env`.
43 lines
1.1 KiB
Rust
43 lines
1.1 KiB
Rust
use crate::ffi::{OsStr, OsString};
|
|
use crate::{fmt, io};
|
|
|
|
pub struct Env(!);
|
|
|
|
impl Env {
|
|
// FIXME(https://github.com/rust-lang/rust/issues/114583): Remove this when <OsStr as Debug>::fmt matches <str as Debug>::fmt.
|
|
pub fn str_debug(&self) -> impl fmt::Debug + '_ {
|
|
let Self(inner) = self;
|
|
match *inner {}
|
|
}
|
|
}
|
|
|
|
impl fmt::Debug for Env {
|
|
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
let Self(inner) = self;
|
|
match *inner {}
|
|
}
|
|
}
|
|
|
|
impl Iterator for Env {
|
|
type Item = (OsString, OsString);
|
|
fn next(&mut self) -> Option<(OsString, OsString)> {
|
|
let Self(inner) = self;
|
|
match *inner {}
|
|
}
|
|
}
|
|
|
|
pub fn env() -> Env {
|
|
panic!("not supported on this platform")
|
|
}
|
|
|
|
pub fn getenv(_: &OsStr) -> Option<OsString> {
|
|
None
|
|
}
|
|
|
|
pub unsafe fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> {
|
|
Err(io::const_error!(io::ErrorKind::Unsupported, "cannot set env vars on this platform"))
|
|
}
|
|
|
|
pub unsafe fn unsetenv(_: &OsStr) -> io::Result<()> {
|
|
Err(io::const_error!(io::ErrorKind::Unsupported, "cannot unset env vars on this platform"))
|
|
}
|