From b8539071cd1d5f091dc9030c0a0e99680ea538f8 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Fri, 12 Jul 2024 23:52:47 +1000 Subject: [PATCH] Use `CompactString::const_new` when possible Signed-off-by: Jiahao XU --- crates/binstalk-git-repo-api/src/gh_api_client/error.rs | 2 +- crates/binstalk-manifests/src/cargo_config.rs | 2 +- crates/binstalk-registry/src/common.rs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/binstalk-git-repo-api/src/gh_api_client/error.rs b/crates/binstalk-git-repo-api/src/gh_api_client/error.rs index 1787a372..0a2918a9 100644 --- a/crates/binstalk-git-repo-api/src/gh_api_client/error.rs +++ b/crates/binstalk-git-repo-api/src/gh_api_client/error.rs @@ -197,7 +197,7 @@ mod test { assert_matches!(deserialize("RATE_LIMITED"), GraphQLErrorType::RateLimited); assert_matches!( deserialize("rATE_LIMITED"), - GraphQLErrorType::Other(val) if val == CompactString::new("rATE_LIMITED") + GraphQLErrorType::Other(val) if val == CompactString::const_new("rATE_LIMITED") ); } } diff --git a/crates/binstalk-manifests/src/cargo_config.rs b/crates/binstalk-manifests/src/cargo_config.rs index d59a0a36..a92cc104 100644 --- a/crates/binstalk-manifests/src/cargo_config.rs +++ b/crates/binstalk-manifests/src/cargo_config.rs @@ -218,7 +218,7 @@ root = "/some/path" # `cargo install` destination directory assert_eq!(env.len(), 3); assert_eq!( env.get("ENV_VAR_NAME").unwrap(), - &Env::Value(CompactString::new("value")) + &Env::Value(CompactString::const_new("value")) ); assert_eq!( env.get("ENV_VAR_NAME_2").unwrap(), diff --git a/crates/binstalk-registry/src/common.rs b/crates/binstalk-registry/src/common.rs index 5847e43a..cd426298 100644 --- a/crates/binstalk-registry/src/common.rs +++ b/crates/binstalk-registry/src/common.rs @@ -96,10 +96,10 @@ pub(super) fn crate_prefix_components( match (chars.next(), chars.next(), chars.next(), chars.next()) { (None, None, None, None) => Err(RegistryError::NotFound(crate_name.into())), - (Some(_), None, None, None) => Ok((CompactString::new("1"), None)), - (Some(_), Some(_), None, None) => Ok((CompactString::new("2"), None)), + (Some(_), None, None, None) => Ok((CompactString::const_new("1"), None)), + (Some(_), Some(_), None, None) => Ok((CompactString::const_new("2"), None)), (Some(ch), Some(_), Some(_), None) => Ok(( - CompactString::new("3"), + CompactString::const_new("3"), Some(ch.to_lowercase().to_compact_string()), )), (Some(a), Some(b), Some(c), Some(d)) => Ok((