Skip to content

Commit

Permalink
webapp: Sync PartialOrd and Ord implementations (clippy)
Browse files Browse the repository at this point in the history
AMDmi3 committed Dec 13, 2024

Unverified

This user has not yet uploaded their public signing key.
1 parent a97cc47 commit 5607bd6
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions repology-webapp/src/package/summarization.rs
Original file line number Diff line number Diff line change
@@ -57,27 +57,25 @@ impl PartialEq<Self> for DisplayVersion {

impl PartialOrd for DisplayVersion {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(
self.metaorder
.cmp(&other.metaorder)
.then_with(|| {
libversion::version_compare(
(&self.version, self.versionflags),
(&other.version, other.versionflags),
)
})
.then_with(|| self.status.cmp(&other.status))
.then_with(|| self.vulnerable.cmp(&other.vulnerable).reverse())
.then_with(|| self.recalled.cmp(&other.recalled).reverse())
.then_with(|| self.spread.cmp(&other.spread))
.then_with(|| self.version.cmp(&other.version)),
)
Some(self.cmp(other))
}
}

impl Ord for DisplayVersion {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.partial_cmp(other).unwrap()
self.metaorder
.cmp(&other.metaorder)
.then_with(|| {
libversion::version_compare(
(&self.version, self.versionflags),
(&other.version, other.versionflags),
)
})
.then_with(|| self.status.cmp(&other.status))
.then_with(|| self.vulnerable.cmp(&other.vulnerable).reverse())
.then_with(|| self.recalled.cmp(&other.recalled).reverse())
.then_with(|| self.spread.cmp(&other.spread))
.then_with(|| self.version.cmp(&other.version))
}
}

0 comments on commit 5607bd6

Please sign in to comment.