Skip to content

Commit

Permalink
doc: Add mod level documents
Browse files Browse the repository at this point in the history
  • Loading branch information
linyihai committed Aug 22, 2024
1 parent 7c4236e commit c4d7d74
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/cargo/util/semver_eval_ext.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//! Extend `semver::VersionReq` with [`matches_prerelease`] which doesn't preclude pre-releases by default.
//!
//! Please refer to the semantic proposal, see [RFC 3493].
//!
//! [RFC 3493]: https://rust-lang.github.io/rfcs/3493-precise-pre-release-cargo-update.html
use semver::{Comparator, Op, Prerelease, Version, VersionReq};

pub(crate) fn matches_prerelease(req: &VersionReq, ver: &Version) -> bool {
Expand Down Expand Up @@ -33,6 +39,7 @@ fn matches_prerelease_impl(cmp: &Comparator, ver: &Version) -> bool {
}
}

// See https://github.com/dtolnay/semver/blob/69efd3cc770ead273a06ad1788477b3092996d29/src/eval.rs#L44-L62
fn matches_exact(cmp: &Comparator, ver: &Version) -> bool {
if ver.major != cmp.major {
return false;
Expand All @@ -53,6 +60,7 @@ fn matches_exact(cmp: &Comparator, ver: &Version) -> bool {
ver.pre == cmp.pre
}

// See https://github.com/dtolnay/semver/blob/69efd3cc770ead273a06ad1788477b3092996d29/src/eval.rs#L64-L88
fn matches_greater(cmp: &Comparator, ver: &Version) -> bool {
if ver.major != cmp.major {
return ver.major > cmp.major;
Expand All @@ -79,6 +87,7 @@ fn matches_greater(cmp: &Comparator, ver: &Version) -> bool {
ver.pre > cmp.pre
}

// See https://github.com/dtolnay/semver/blob/69efd3cc770ead273a06ad1788477b3092996d29/src/eval.rs#L90-L114
fn matches_less(cmp: &Comparator, ver: &Version) -> bool {
if ver.major != cmp.major {
return ver.major < cmp.major;
Expand Down

0 comments on commit c4d7d74

Please sign in to comment.