From aaf8da504251836964f361a70eb8d64d5fb77c83 Mon Sep 17 00:00:00 2001 From: Andrey Yantsen Date: Mon, 24 Jul 2023 21:07:26 +0100 Subject: [PATCH] refactor: fix warning from the nightly clippy --- Cargo.toml | 1 + crates/plex-api/build.rs | 4 +-- crates/xtask/src/get_last_plex_tags.rs | 36 ++++++++++++++------------ 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9d36a341..ea59522a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] +resolver = "2" members = [ "crates/plex-api", "crates/plex-api-test-helper", diff --git a/crates/plex-api/build.rs b/crates/plex-api/build.rs index 2caad81c..7704fee3 100644 --- a/crates/plex-api/build.rs +++ b/crates/plex-api/build.rs @@ -52,13 +52,13 @@ impl Feature { impl PartialOrd for Feature { fn partial_cmp(&self, other: &Self) -> Option { - self.enum_name().partial_cmp(&other.enum_name()) + Some(self.cmp(other)) } } impl Ord for Feature { fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.partial_cmp(other).unwrap() + self.enum_name().cmp(&other.enum_name()) } } diff --git a/crates/xtask/src/get_last_plex_tags.rs b/crates/xtask/src/get_last_plex_tags.rs index 6efbbe19..f216fdbf 100644 --- a/crates/xtask/src/get_last_plex_tags.rs +++ b/crates/xtask/src/get_last_plex_tags.rs @@ -119,46 +119,48 @@ enum SemverOrString<'a> { // * semver tags sorted in descending order impl<'a> PartialOrd for SemverOrString<'a> { fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +impl<'a> Ord for SemverOrString<'a> { + fn cmp(&self, other: &Self) -> Ordering { if let SemverOrString::Str(s) = self { if s == &"latest" { - return Some(Ordering::Less); + return Ordering::Less; } if let SemverOrString::Str(s2) = other { if s2 != &"latest" { - return Some(s.cmp(s2)); + return s.cmp(s2); } else { - return Some(Ordering::Greater); + return Ordering::Greater; } } - return Some(Ordering::Less); + Ordering::Less } else if let SemverOrString::Str(s) = other { if s == &"latest" { - return Some(Ordering::Greater); + return Ordering::Greater; } if let SemverOrString::Str(s2) = self { if s2 != &"latest" { - return Some(s2.cmp(s)); + return s2.cmp(s); } else { - return Some(Ordering::Less); + return Ordering::Less; } } - return Some(Ordering::Greater); + Ordering::Greater } else if let SemverOrString::Semver(v) = self { if let SemverOrString::Semver(v2) = other { - return Some(v.cmp(v2).reverse()); + return v.cmp(v2).reverse(); + } else { + return Ordering::Less; } + } else { + return Ordering::Greater; } - - None - } -} - -impl<'a> Ord for SemverOrString<'a> { - fn cmp(&self, other: &Self) -> Ordering { - self.partial_cmp(other).unwrap() } }