From 47f79a966063be0605504906604f97dae0c12e99 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Wed, 19 Jul 2023 12:15:57 +1000 Subject: [PATCH] Fix loading `.cargo/config.toml` (#1217) Fixed #1216 Signed-off-by: Jiahao XU --- crates/bin/src/entry.rs | 4 ++-- crates/binstalk-manifests/src/cargo_config.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bin/src/entry.rs b/crates/bin/src/entry.rs index 4fa03672..a51f16b3 100644 --- a/crates/bin/src/entry.rs +++ b/crates/bin/src/entry.rs @@ -148,7 +148,7 @@ pub fn install_crates( index } else if let Some(registry_name) = args .registry - .or_else(|| config.registry.map(|registry| registry.default)) + .or_else(|| config.registry.and_then(|registry| registry.default)) { env::var(format!("CARGO_REGISTRIES_{registry_name}_INDEX")) .map(Cow::Owned) @@ -157,7 +157,7 @@ pub fn install_crates( .registries .as_ref() .and_then(|registries| registries.get(®istry_name)) - .map(|registry| Cow::Borrowed(registry.index.as_str())) + .and_then(|registry| registry.index.as_deref().map(Cow::Borrowed)) .ok_or_else(|| BinstallError::UnknownRegistryName(registry_name)) })? .parse() diff --git a/crates/binstalk-manifests/src/cargo_config.rs b/crates/binstalk-manifests/src/cargo_config.rs index 195650eb..21fac013 100644 --- a/crates/binstalk-manifests/src/cargo_config.rs +++ b/crates/binstalk-manifests/src/cargo_config.rs @@ -52,12 +52,12 @@ pub enum Env { #[derive(Debug, Deserialize)] pub struct Registry { - pub index: CompactString, + pub index: Option, } #[derive(Debug, Deserialize)] pub struct DefaultRegistry { - pub default: CompactString, + pub default: Option, } #[derive(Debug, Default, Deserialize)]