mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-07 20:50:03 +00:00
Use CompactString
for field Resolution::Fetch::version
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
d430c077d4
commit
b7cfa0aa64
1 changed files with 7 additions and 7 deletions
|
@ -4,7 +4,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use cargo_toml::{Package, Product};
|
use cargo_toml::{Package, Product};
|
||||||
use compact_str::CompactString;
|
use compact_str::{format_compact, CompactString};
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
use miette::{miette, Result};
|
use miette::{miette, Result};
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
|
@ -21,7 +21,7 @@ pub enum Resolution {
|
||||||
fetcher: Arc<dyn Fetcher>,
|
fetcher: Arc<dyn Fetcher>,
|
||||||
package: Package<Meta>,
|
package: Package<Meta>,
|
||||||
name: CompactString,
|
name: CompactString,
|
||||||
version: String,
|
version: CompactString,
|
||||||
bin_path: PathBuf,
|
bin_path: PathBuf,
|
||||||
bin_files: Vec<bins::BinFile>,
|
bin_files: Vec<bins::BinFile>,
|
||||||
},
|
},
|
||||||
|
@ -83,11 +83,11 @@ pub async fn resolve(
|
||||||
) -> Result<Resolution> {
|
) -> Result<Resolution> {
|
||||||
info!("Installing package: '{}'", crate_name);
|
info!("Installing package: '{}'", crate_name);
|
||||||
|
|
||||||
let mut version = match (&crate_name.version, &opts.version) {
|
let mut version: CompactString = match (&crate_name.version, &opts.version) {
|
||||||
(Some(version), None) => version.to_string(),
|
(Some(version), None) => version.clone(),
|
||||||
(None, Some(version)) => version.to_string(),
|
(None, Some(version)) => version.into(),
|
||||||
(Some(_), Some(_)) => Err(BinstallError::SuperfluousVersionOption)?,
|
(Some(_), Some(_)) => Err(BinstallError::SuperfluousVersionOption)?,
|
||||||
(None, None) => "*".to_string(),
|
(None, None) => "*".into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Treat 0.1.2 as =0.1.2
|
// Treat 0.1.2 as =0.1.2
|
||||||
|
@ -97,7 +97,7 @@ pub async fn resolve(
|
||||||
.map(|ch| ch.is_ascii_digit())
|
.map(|ch| ch.is_ascii_digit())
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
{
|
{
|
||||||
version.insert(0, '=');
|
version = format_compact!("={version}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch crate via crates.io, git, or use a local manifest path
|
// Fetch crate via crates.io, git, or use a local manifest path
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue