Skip to content

Commit

Permalink
refactor(util): Align VersionExt, PartialVersion naming
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Nov 6, 2023
1 parent 44d145a commit d49cc62
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/cargo/core/package_id_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl PackageIdSpec {

/// Full `semver::Version`, if present
pub fn version(&self) -> Option<Version> {
self.version.as_ref().and_then(|v| v.version())
self.version.as_ref().and_then(|v| v.to_version())
}

pub fn partial_version(&self) -> Option<&PartialVersion> {
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ pub fn create_bcx<'a, 'cfg>(
continue;
};

let req = version.caret_req();
let req = version.to_caret_req();
if req.matches(&untagged_version) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/ops/common_for_install_and_uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ where
match deps.iter().max_by_key(|p| p.package_id()) {
Some(summary) => {
if let (Some(current), Some(msrv)) = (current_rust_version, summary.rust_version()) {
let msrv_req = msrv.caret_req();
let msrv_req = msrv.to_caret_req();
if !msrv_req.matches(current) {
let name = summary.name();
let ver = summary.version();
Expand All @@ -574,7 +574,7 @@ where
.filter(|summary| {
summary
.rust_version()
.map(|msrv| msrv.caret_req().matches(current))
.map(|msrv| msrv.to_caret_req().matches(current))
.unwrap_or(true)
})
.max_by_key(|s| s.package_id())
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/util/semver_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub struct PartialVersion {
}

impl PartialVersion {
pub fn version(&self) -> Option<Version> {
pub fn to_version(&self) -> Option<Version> {
Some(Version {
major: self.major,
minor: self.minor?,
Expand All @@ -217,7 +217,7 @@ impl PartialVersion {
})
}

pub fn caret_req(&self) -> VersionReq {
pub fn to_caret_req(&self) -> VersionReq {
VersionReq {
comparators: vec![Comparator {
op: semver::Op::Caret,
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ impl schema::TomlManifest {
let rust_version = rust_version
.clone()
.resolve("rust_version", || inherit()?.rust_version())?;
let req = rust_version.caret_req();
let req = rust_version.to_caret_req();
if let Some(first_version) = edition.first_version() {
let unsupported =
semver::Version::new(first_version.major, first_version.minor - 1, 9999);
Expand Down

0 comments on commit d49cc62

Please sign in to comment.