From 6c9b22ebc08ce2a76d03786654b311a44f652ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dj8yf0=CE=BCl?= Date: Thu, 24 Oct 2024 22:20:19 +0300 Subject: [PATCH] chore: wrap some CrateMetadata code into block --- cargo-near-build/src/types/cargo/metadata.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cargo-near-build/src/types/cargo/metadata.rs b/cargo-near-build/src/types/cargo/metadata.rs index cfec66f8..47174278 100644 --- a/cargo-near-build/src/types/cargo/metadata.rs +++ b/cargo-near-build/src/types/cargo/metadata.rs @@ -25,11 +25,14 @@ impl CrateMetadata { no_locked: bool, cargo_target_dir: Option<&buildtime_env::CargoTargetDir>, ) -> eyre::Result { - let (mut metadata, root_package) = - get_cargo_metadata(&manifest_path, no_locked, cargo_target_dir)?; - - metadata.target_directory = crate::fs::force_canonicalize_dir(&metadata.target_directory)?; - metadata.workspace_root = metadata.workspace_root.canonicalize_utf8()?; + let (metadata, root_package) = { + let (mut metadata, root_package) = + get_cargo_metadata(&manifest_path, no_locked, cargo_target_dir)?; + metadata.target_directory = + crate::fs::force_canonicalize_dir(&metadata.target_directory)?; + metadata.workspace_root = metadata.workspace_root.canonicalize_utf8()?; + (metadata, root_package) + }; let mut target_directory = crate::fs::force_canonicalize_dir(&metadata.target_directory.join("near"))?; @@ -89,11 +92,11 @@ impl CrateMetadata { .deps .iter() .find(|dep| dep.name == dependency_name) - .and_then(|near_sdk| { + .and_then(|found_dependency| { self.raw_metadata .packages .iter() - .find(|pkg| pkg.id == near_sdk.pkg) + .find(|pkg| pkg.id == found_dependency.pkg) }) .wrap_err(format!("`{}` dependency not found", dependency_name)) }