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
15
src/main.rs
15
src/main.rs
|
@ -308,9 +308,12 @@ async fn entry() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let desired_targets = desired_targets.get().await;
|
let desired_targets = desired_targets.get().await;
|
||||||
let target = desired_targets
|
let target = Arc::from(
|
||||||
.first()
|
desired_targets
|
||||||
.ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?;
|
.first()
|
||||||
|
.ok_or_else(|| miette!("No viable targets found, try with `--targets`"))?
|
||||||
|
.as_str(),
|
||||||
|
);
|
||||||
|
|
||||||
let tasks: Vec<_> = resolutions
|
let tasks: Vec<_> = resolutions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -334,7 +337,7 @@ async fn entry() -> Result<()> {
|
||||||
)),
|
)),
|
||||||
Resolution::InstallFromSource { package } => {
|
Resolution::InstallFromSource { package } => {
|
||||||
if !opts.dry_run {
|
if !opts.dry_run {
|
||||||
tokio::spawn(install_from_source(package, target.clone()))
|
tokio::spawn(install_from_source(package, Arc::clone(&target)))
|
||||||
} else {
|
} else {
|
||||||
info!(
|
info!(
|
||||||
"Dry-run: running `cargo install {} --version {} --target {target}`",
|
"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!(
|
debug!(
|
||||||
"Running `cargo install {} --version {} --target {target}`",
|
"Running `cargo install {} --version {} --target {target}`",
|
||||||
package.name, package.version
|
package.name, package.version
|
||||||
|
@ -634,7 +637,7 @@ async fn install_from_source(package: Package<Meta>, target: String) -> Result<(
|
||||||
.arg("--version")
|
.arg("--version")
|
||||||
.arg(package.version)
|
.arg(package.version)
|
||||||
.arg("--target")
|
.arg("--target")
|
||||||
.arg(target)
|
.arg(&*target)
|
||||||
.spawn()
|
.spawn()
|
||||||
.into_diagnostic()
|
.into_diagnostic()
|
||||||
.wrap_err("Spawning cargo install failed.")?;
|
.wrap_err("Spawning cargo install failed.")?;
|
||||||
|
|
Loading…
Add table
Reference in a new issue