one more use of entry
authorEh2406 <YeomanYaacov@gmail.com>
Tue, 27 Feb 2018 02:46:59 +0000 (21:46 -0500)
committerEh2406 <YeomanYaacov@gmail.com>
Tue, 27 Feb 2018 02:46:59 +0000 (21:46 -0500)
src/cargo/core/resolver/mod.rs

index bb0e60404135ed7d09c928b7665aea6a43873f1a..a57695eb1f98934ede052ee0148b0a6b41e331fc 100644 (file)
@@ -576,7 +576,11 @@ impl RemainingCandidates {
         }
     }
 
-    fn next(&mut self, prev_active: &[Summary], links: &HashMap<String, PackageId>) -> Result<(Candidate, bool), HashMap<PackageId, ConflictReason>> {
+    fn next(
+        &mut self,
+        prev_active: &[Summary],
+        links: &HashMap<String, PackageId>,
+    ) -> Result<(Candidate, bool), HashMap<PackageId, ConflictReason>> {
         // Filter the set of candidates based on the previously activated
         // versions for this dependency. We can actually use a version if it
         // precisely matches an activated version or if it is otherwise
@@ -594,8 +598,10 @@ impl RemainingCandidates {
             if let Some(link) = b.summary.links() {
                 if let Some(a) = links.get(link) {
                     if a != b.summary.package_id() {
-                        self.conflicting_prev_active.insert(a.clone(), ConflictReason::Links(link.to_owned()));
-                        continue
+                        self.conflicting_prev_active
+                            .entry(a.clone())
+                            .or_insert_with(|| ConflictReason::Links(link.to_owned()));
+                        continue;
                     }
                 }
             }
@@ -604,7 +610,9 @@ impl RemainingCandidates {
                 .find(|a| compatible(a.version(), b.summary.version()))
             {
                 if *a != b.summary {
-                    self.conflicting_prev_active.insert(a.package_id().clone(), ConflictReason::Semver);
+                    self.conflicting_prev_active
+                        .entry(a.package_id().clone())
+                        .or_insert(ConflictReason::Semver);
                     continue;
                 }
             }