From 2f9b700d82c653168657f7802857d658fc16e3bc Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Tue, 16 Mar 2021 10:32:09 -0700 Subject: [PATCH] Simplify 'Version::to_mmp()'. --- src/version.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/version.rs b/src/version.rs index a37d8d6..2bc18aa 100644 --- a/src/version.rs +++ b/src/version.rs @@ -59,13 +59,13 @@ impl Version { .nth(0) .unwrap_or("") .split('.') - .map(|s| s.parse::().ok()); + .map(|s| s.parse::()); let mut mmp = [0u16; 3]; for (i, split) in splits.enumerate() { mmp[i] = match (i, split) { - (3, _) | (_, None) => return None, - (_, Some(v)) => v, + (3, _) | (_, Err(_)) => return None, + (_, Ok(v)) => v, }; } @@ -103,8 +103,8 @@ impl Version { /// ``` pub fn to_mmp(&self) -> (u16, u16, u16) { let major = self.0 >> 32; - let minor = (self.0 << 32) >> 48; - let patch = (self.0 << 48) >> 48; + let minor = self.0 >> 16; + let patch = self.0; (major as u16, minor as u16, patch as u16) }