#![deny(unsafe_code)]
pub mod dirs;
pub mod path;
#[cfg(test)]
#[path = "path_tests.rs"]
mod path_tests;
#[cfg(test)]
#[path = "dirs_tests.rs"]
mod dirs_tests;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Platform {
Linux,
Macos,
Windows,
}
impl Platform {
pub const HOST: Platform = if cfg!(windows) {
Platform::Windows
} else if cfg!(target_os = "macos") {
Platform::Macos
} else {
Platform::Linux
};
pub const fn is_windows(self) -> bool {
matches!(self, Platform::Windows)
}
#[cfg(test)]
pub const ALL: [Platform; 3] = [Platform::Linux, Platform::Macos, Platform::Windows];
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn host_matches_the_compilation_target() {
assert_eq!(Platform::HOST.is_windows(), cfg!(windows));
assert_eq!(
Platform::HOST == Platform::Macos,
cfg!(all(target_os = "macos", not(windows)))
);
assert!(Platform::ALL.contains(&Platform::HOST));
}
}