use entry to not hash twice thanks clippy
authorEh2406 <YeomanYaacov@gmail.com>
Sat, 24 Feb 2018 04:06:10 +0000 (23:06 -0500)
committerEh2406 <YeomanYaacov@gmail.com>
Mon, 26 Feb 2018 22:31:02 +0000 (17:31 -0500)
(cherry picked from commit de9a7b9)

src/cargo/ops/cargo_read_manifest.rs

index 48c2d9dabe123d4cf97e16429c4398985323ef97..13ce7affd608da0b6fca157fdf5f58d6172b9352 100644 (file)
@@ -138,11 +138,13 @@ fn read_nested_packages(path: &Path,
     let pkg = Package::new(manifest, &manifest_path);
 
     let pkg_id = pkg.package_id().clone();
-    if !all_packages.contains_key(&pkg_id) {
-        all_packages.insert(pkg_id, pkg);
-    } else {
-        info!("skipping nested package `{}` found at `{}`",
-              pkg.name(), path.to_string_lossy());
+    use ::std::collections::hash_map::Entry;
+    match all_packages.entry(pkg_id) {
+        Entry::Vacant(v) => { v.insert(pkg); },
+        Entry::Occupied(_) => {
+            info!("skipping nested package `{}` found at `{}`",
+                  pkg.name(), path.to_string_lossy());
+        }
     }
 
     // Registry sources are not allowed to have `path=` dependencies because