From 1f86849a976fa6cc6d39cc941093bb67e938a74d Mon Sep 17 00:00:00 2001 From: Yijun Yu Date: Mon, 4 Jan 2021 13:06:52 +0000 Subject: [PATCH] Fixing an error when the crate's name mismatches it will panic due to unwrap(), instead we can use unwrap_or() to avoid being panic. --- cargo-geiger/src/mapping/geiger.rs | 4 +--- cargo-geiger/src/mapping/metadata.rs | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cargo-geiger/src/mapping/geiger.rs b/cargo-geiger/src/mapping/geiger.rs index 85b760d3..12d16e76 100644 --- a/cargo-geiger/src/mapping/geiger.rs +++ b/cargo-geiger/src/mapping/geiger.rs @@ -50,9 +50,7 @@ fn handle_source_repr(source_repr: &str) -> cargo_geiger_serde::Source { rev: String::from(revision), } } - _ => { - panic!("Unrecognised source type: {}", source_type) - } + _ => panic!("Unrecognised source type: {}", source_type), } } diff --git a/cargo-geiger/src/mapping/metadata.rs b/cargo-geiger/src/mapping/metadata.rs index 6ef242de..0a36caab 100644 --- a/cargo-geiger/src/mapping/metadata.rs +++ b/cargo-geiger/src/mapping/metadata.rs @@ -59,7 +59,8 @@ impl MatchesIgnoringSource for cargo_metadata::Dependency { self.name == krates .get_package_name_from_cargo_metadata_package_id(&package_id) - .unwrap() + .unwrap_or(package_id.to_string()) + //.unwrap() && self.req.matches( &krates .get_package_version_from_cargo_metadata_package_id(