From: Eh2406 Date: Sat, 24 Feb 2018 04:06:10 +0000 (-0500) Subject: use entry to not hash twice thanks clippy X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~2^2~75^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=836fdacda99fca89c7455698d028dcf720a5aa42;p=cargo.git use entry to not hash twice thanks clippy (cherry picked from commit de9a7b9) --- diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index 48c2d9dab..13ce7affd 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -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