Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(BREAKING): deprecate matches #25

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,20 @@ impl VersionReq {
}
}

pub fn range(&self) -> Option<&VersionRangeSet> {
match &self.inner {
RangeSetOrTag::RangeSet(range_set) => Some(range_set),
RangeSetOrTag::Tag(_) => None,
}
}

#[deprecated(note = "check for range first, then use satisfies")]
pub fn matches(&self, version: &Version) -> bool {
match &self.inner {
RangeSetOrTag::RangeSet(range_set) => range_set.satisfies(version),
// It's not safe to use `.matches()` with a VersionReq because the tag
// might not be resolved yet. We might want to create a `ResolvedVersionReq`
// that has the tag resolved or think of something better here
RangeSetOrTag::Tag(_) => panic!(
"programming error: cannot use matches with a tag: {}",
self.raw_text
Expand Down
Loading