Skip to content

Commit

Permalink
refactor: fix warning from the nightly clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-yantsen committed Jul 24, 2023
1 parent 794a5c9 commit aaf8da5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]

resolver = "2"
members = [
"crates/plex-api",
"crates/plex-api-test-helper",
Expand Down
4 changes: 2 additions & 2 deletions crates/plex-api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ impl Feature {

impl PartialOrd for Feature {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
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())
}
}

Expand Down
36 changes: 19 additions & 17 deletions crates/xtask/src/get_last_plex_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ordering> {
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()
}
}

0 comments on commit aaf8da5

Please sign in to comment.