use super::Env;
use std::path::PathBuf;
#[derive(Debug, Clone, Copy, Default)]
pub struct StdEnv;
impl StdEnv {
#[must_use]
pub const fn new() -> Self {
Self
}
}
impl Env for StdEnv {
fn get(&self, key: &str) -> Option<String> {
std::env::var(key).ok()
}
fn home_dir(&self) -> Option<PathBuf> {
#[cfg(target_os = "windows")]
{
std::env::var("USERPROFILE")
.ok()
.map(PathBuf::from)
.or_else(|| std::env::var("HOME").ok().map(PathBuf::from))
}
#[cfg(not(target_os = "windows"))]
{
std::env::var("HOME").ok().map(PathBuf::from)
}
}
}