mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 05:28:42 +00:00
Use CompactString
for fields of CrateName
Since most of the time, they are shorter than 24 bytes. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
caeb49ce33
commit
d430c077d4
2 changed files with 8 additions and 6 deletions
|
@ -4,6 +4,7 @@ use std::{
|
|||
};
|
||||
|
||||
use cargo_toml::{Package, Product};
|
||||
use compact_str::CompactString;
|
||||
use log::{debug, error, info, warn};
|
||||
use miette::{miette, Result};
|
||||
use reqwest::Client;
|
||||
|
@ -19,7 +20,7 @@ pub enum Resolution {
|
|||
Fetch {
|
||||
fetcher: Arc<dyn Fetcher>,
|
||||
package: Package<Meta>,
|
||||
name: String,
|
||||
name: CompactString,
|
||||
version: String,
|
||||
bin_path: PathBuf,
|
||||
bin_files: Vec<bins::BinFile>,
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
use std::{convert::Infallible, fmt, str::FromStr};
|
||||
|
||||
use compact_str::CompactString;
|
||||
use itertools::Itertools;
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub struct CrateName {
|
||||
pub name: String,
|
||||
pub version: Option<String>,
|
||||
pub name: CompactString,
|
||||
pub version: Option<CompactString>,
|
||||
}
|
||||
|
||||
impl fmt::Display for CrateName {
|
||||
|
@ -26,12 +27,12 @@ impl FromStr for CrateName {
|
|||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
Ok(if let Some((name, version)) = s.split_once('@') {
|
||||
CrateName {
|
||||
name: name.to_string(),
|
||||
version: Some(version.to_string()),
|
||||
name: name.into(),
|
||||
version: Some(version.into()),
|
||||
}
|
||||
} else {
|
||||
CrateName {
|
||||
name: s.to_string(),
|
||||
name: s.into(),
|
||||
version: None,
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue