use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Platform {
Linux,
Macos,
Windows,
}
impl Platform {
pub const fn current() -> Self {
if cfg!(target_os = "windows") {
Platform::Windows
} else if cfg!(target_os = "macos") {
Platform::Macos
} else {
Platform::Linux
}
}
pub const fn as_str(self) -> &'static str {
match self {
Platform::Linux => "linux",
Platform::Macos => "macos",
Platform::Windows => "windows",
}
}
}
impl fmt::Display for Platform {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}