From 6fe7b40e03f0eb7db51813473230705890406820 Mon Sep 17 00:00:00 2001 From: Denis Cornehl Date: Sun, 22 Sep 2024 14:48:21 +0200 Subject: [PATCH] extend comment on match_version semver match --- src/web/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/web/mod.rs b/src/web/mod.rs index 73242b532..8c4443254 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -241,6 +241,7 @@ fn semver_match<'a, F: Fn(&Release) -> bool>( req: &VersionReq, filter: F, ) -> Option<&'a Release> { + // first try standard semver match using `VersionReq::match`, should handle most cases. if let Some(release) = releases .iter() .filter(|release| filter(release)) @@ -249,8 +250,9 @@ fn semver_match<'a, F: Fn(&Release) -> bool>( Some(release) } else if req == &VersionReq::STAR { // semver `*` does not match pre-releases. - // When someone wants the latest release and we have only pre-releases - // just return the latest prerelease. + // So when we only have pre-releases, `VersionReq::STAR` would lead to an + // empty result. + // In this case we just return the latest latest prerelase instead of nothing. return releases.iter().find(|release| filter(release)); } else { None