From b0dccef7f89672895df54ab10492c3f86144dd90 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Tue, 14 Nov 2023 14:53:21 -0600 Subject: [PATCH] simpler --- crates/libs/version/src/lib.rs | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/crates/libs/version/src/lib.rs b/crates/libs/version/src/lib.rs index 42027ffe2b..18af4349c3 100644 --- a/crates/libs/version/src/lib.rs +++ b/crates/libs/version/src/lib.rs @@ -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`.