Use match over elif

This commit is contained in:
Love 2025-01-07 17:31:27 +01:00
parent 0d3ca81319
commit dde5468e2b

View File

@ -11,15 +11,11 @@ pub enum Os {
impl Os { impl Os {
pub fn get_current() -> Option<Self> { pub fn get_current() -> Option<Self> {
let os_str = env::consts::OS; match env::consts::OS {
if os_str == "windows" { "windows" => Some(Self::Windows),
Some(Os::Windows) "macos" => Some(Self::Mac),
} else if os_str == "macos" { os_str if os_str == "linux" || os_str.contains("bsd") => Some(Self::Unix),
Some(Os::Mac) _ => None,
} else if os_str == "linux" || os_str.contains("bsd") {
Some(Os::Unix)
} else {
None
} }
} }