Skip to content

Commit

Permalink
Swap order of semver comparison when returning search results
Browse files Browse the repository at this point in the history
This should fix a regression introduced in this commit series.
  • Loading branch information
jtgeibel committed Mar 8, 2018
1 parent 881ff2c commit baadd1d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/controllers/krate/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub fn search(req: &mut Request) -> CargoResult<Response> {
.map(|versions| {
versions
.into_iter()
.max_by(Version::semantically_newest_first)
.max_by(Version::semver_cmp)
.unwrap()
})
.collect::<Vec<_>>();
Expand Down
4 changes: 2 additions & 2 deletions src/version/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ impl Version {
}

/// Orders SemVer numbers so that "higher" version numbers appear first.
pub fn semantically_newest_first(a: &Self, b: &Self) -> ::std::cmp::Ordering {
b.num.cmp(&a.num)
pub fn semver_cmp(a: &Self, b: &Self) -> ::std::cmp::Ordering {
a.num.cmp(&b.num)
}
}

Expand Down

0 comments on commit baadd1d

Please sign in to comment.