Skip to content

Commit

Permalink
simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr committed Nov 14, 2023
1 parent d1ac758 commit b0dccef
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions crates/libs/version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,15 @@ impl Version {

/// Determines if the currently running operating system version is greater than or equal to the version of `self`.
pub fn ge(&self) -> bool {
use core::cmp::Ordering::*;
let current = Self::current();

match current.major.cmp(&self.major) {
Greater => true,
Less => false,
Equal => match current.minor.cmp(&self.minor) {
Greater => true,
Less => false,
Equal => match current.pack.cmp(&self.pack) {
Greater => true,
Less => false,
Equal => match current.build.cmp(&self.build) {
Greater => true,
Less => false,
Equal => true,
},
},
},
}
current
.major
.cmp(&self.major)
.then_with(|| current.minor.cmp(&self.minor))
.then_with(|| current.pack.cmp(&self.pack))
.then_with(|| current.build.cmp(&self.build))
.is_ge()
}

/// Hook used for testing `ge`.
Expand Down

0 comments on commit b0dccef

Please sign in to comment.