From b68b3c4b1c8b003f5c8331e92f2820a7d3f0812a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalle=20Lindstr=C3=B6m?= Date: Thu, 21 Nov 2024 17:12:19 +0100 Subject: [PATCH] Address review feedback --- mullvad-version/src/lib.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mullvad-version/src/lib.rs b/mullvad-version/src/lib.rs index 69675f83dce1..e1446a8dcf15 100644 --- a/mullvad-version/src/lib.rs +++ b/mullvad-version/src/lib.rs @@ -79,7 +79,7 @@ impl FromStr for Version { fn from_str(version: &str) -> Result { static VERSION_REGEX: LazyLock = LazyLock::new(|| { Regex::new( - r"(?x) + r"(?x) # enable insignificant whitespace mode 20(?\d{2})\. # the last two digits of the year (?[1-9]\d?) # the incrementing version number (?: # (optional) alpha or beta or dev @@ -116,17 +116,18 @@ impl FromStr for Version { .map(|m| m.as_str()) .or(captures.name("no_ver_dev").map(|_| "")); - let sub_type = match (alpha, beta, dev) { - (Some(v), _, _) => VersionType::Alpha(v.to_owned()), - (_, Some(v), _) => VersionType::Beta(v.to_owned()), - (_, _, Some(v)) => VersionType::Dev(v.to_owned()), + let version_type = match (alpha, beta, dev) { (None, None, None) => VersionType::Stable, + (Some(v), None, None) => VersionType::Alpha(v.to_owned()), + (None, Some(v), None) => VersionType::Beta(v.to_owned()), + (None, None, Some(v)) => VersionType::Dev(v.to_owned()), + _ => return Err(format!("Invalid version: {version}")), }; Ok(Version { year, incremental, - version_type: sub_type, + version_type, }) } }