From 70733a921389b67da80fb5dd7dad6b9bbb16d8c6 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 17 Apr 2021 11:33:51 -0400 Subject: [PATCH] minor cleanup --- src/cargo/core/compiler/custom_build.rs | 13 ++----------- src/cargo/core/package.rs | 4 ++++ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index 86f00a84dda..e6d284123d0 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -267,12 +267,7 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult { } }) .collect::>(); - let library_name = unit - .pkg - .targets() - .iter() - .find(|t| t.is_lib()) - .map(|t| t.crate_name()); + let library_name = unit.pkg.library().map(|t| t.crate_name()); let pkg_descr = unit.pkg.to_string(); let build_script_outputs = Arc::clone(&cx.build_script_outputs); let id = unit.pkg.package_id(); @@ -879,11 +874,7 @@ fn prev_build_output(cx: &mut Context<'_, '_>, unit: &Unit) -> (Option &[Target] { self.manifest().targets() } + /// Gets the library crate for this package, if it exists. + pub fn library(&self) -> Option<&Target> { + self.targets().iter().find(|t| t.is_lib()) + } /// Gets the current package version. pub fn version(&self) -> &Version { self.package_id().version()