mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-21 13:08:42 +00:00
Avoid Box::clone
for targets
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
7f11b74f5e
commit
40a872dbe3
1 changed files with 9 additions and 6 deletions
13
src/main.rs
13
src/main.rs
|
@ -308,9 +308,12 @@ async fn entry() -> Result<()> {
|
|||
}
|
||||
|
||||
let desired_targets = desired_targets.get().await;
|
||||
let target = desired_targets
|
||||
let target = Arc::from(
|
||||
desired_targets
|
||||
.first()
|
||||
.ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?;
|
||||
.ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?
|
||||
.as_str(),
|
||||
);
|
||||
|
||||
let tasks: Vec<_> = resolutions
|
||||
.into_iter()
|
||||
|
@ -334,7 +337,7 @@ async fn entry() -> Result<()> {
|
|||
)),
|
||||
Resolution::InstallFromSource { package } => {
|
||||
if !opts.dry_run {
|
||||
tokio::spawn(install_from_source(package, target.clone()))
|
||||
tokio::spawn(install_from_source(package, Arc::clone(&target)))
|
||||
} else {
|
||||
info!(
|
||||
"Dry-run: running `cargo install {} --version {} --target {target}`",
|
||||
|
@ -623,7 +626,7 @@ async fn install_from_package(
|
|||
})
|
||||
}
|
||||
|
||||
async fn install_from_source(package: Package<Meta>, target: String) -> Result<()> {
|
||||
async fn install_from_source(package: Package<Meta>, target: Arc<str>) -> Result<()> {
|
||||
debug!(
|
||||
"Running `cargo install {} --version {} --target {target}`",
|
||||
package.name, package.version
|
||||
|
@ -634,7 +637,7 @@ async fn install_from_source(package: Package<Meta>, target: String) -> Result<(
|
|||
.arg("--version")
|
||||
.arg(package.version)
|
||||
.arg("--target")
|
||||
.arg(target)
|
||||
.arg(&*target)
|
||||
.spawn()
|
||||
.into_diagnostic()
|
||||
.wrap_err("Spawning cargo install failed.")?;
|
||||
|
|
Loading…
Add table
Reference in a new issue