Skip to content

Commit a699239

Browse files
committed
chagne ActivationsKey into a struct
1 parent 2525532 commit a699239

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/cargo/core/resolver/context.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ impl ResolverContext {
106106
// versions came from a `[patch]` source.
107107
if let Some((_, dep)) = parent {
108108
if dep.source_id() != id.source_id() {
109-
let key = (id.name(), dep.source_id(), id.version().into());
109+
let key =
110+
ActivationsKey::new(id.name(), dep.source_id(), id.version().into());
110111
let prev = self.activations.insert(key, (summary.clone(), age));
111112
if let Some((previous_summary, _)) = prev {
112113
return Err(

src/cargo/core/resolver/types.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,14 @@ impl ResolveOpts {
167167
/// A key that when stord in a hash map ensures that there is only one
168168
/// semver compatible version of each crate.
169169
/// Find the activated version of a crate based on the name, source, and semver compatibility.
170-
pub type ActivationsKey = (InternedString, SourceId, SemverCompatibility);
170+
#[derive(Clone, PartialEq, Eq, Debug, Ord, PartialOrd, Hash)]
171+
pub struct ActivationsKey(InternedString, SourceId, SemverCompatibility);
172+
173+
impl ActivationsKey {
174+
pub fn new(name: InternedString, source_id: SourceId, ver: SemverCompatibility) -> ActivationsKey {
175+
ActivationsKey(name, source_id, ver)
176+
}
177+
}
171178

172179
/// A type that represents when cargo treats two Versions as compatible.
173180
/// Versions `a` and `b` are compatible if their left-most nonzero digit is the
@@ -193,7 +200,7 @@ impl From<&semver::Version> for SemverCompatibility {
193200

194201
impl PackageId {
195202
pub fn as_activations_key(self) -> ActivationsKey {
196-
(self.name(), self.source_id(), self.version().into())
203+
ActivationsKey(self.name(), self.source_id(), self.version().into())
197204
}
198205
}
199206

0 commit comments

Comments
 (0)