Skip to content

Commit 11165b2

Browse files
authored
refactor: remove redundant .as_str() calls on temporary strings (#12279)
* Update serde_helpers.rs * Update install.rs * Update ext_integration.rs * Update lib.rs * Update script.rs
1 parent e0b9173 commit 11165b2

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

crates/common/src/serde_helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl NumberOrHexU256 {
6363
/// Tries to convert this into a [U256]].
6464
pub fn try_into_u256<E: de::Error>(self) -> Result<U256, E> {
6565
match self {
66-
Self::Int(num) => U256::from_str(num.to_string().as_str()).map_err(E::custom),
66+
Self::Int(num) => U256::from_str(&num.to_string()).map_err(E::custom),
6767
Self::Hex(val) => Ok(val),
6868
}
6969
}

crates/forge/src/cmd/install.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl DependencyInstallOpts {
234234
msg.push_str("\n\n");
235235

236236
if let Some(dep_id) = &dep_id {
237-
msg.push_str(dep_id.to_string().as_str());
237+
msg.push_str(&dep_id.to_string());
238238
} else {
239239
msg.push_str(tag);
240240
}
@@ -252,7 +252,7 @@ impl DependencyInstallOpts {
252252
msg.push(' ');
253253

254254
if let Some(dep_id) = dep_id {
255-
msg.push_str(dep_id.to_string().as_str());
255+
msg.push_str(&dep_id.to_string());
256256
} else {
257257
msg.push_str(tag.as_str());
258258
}

crates/forge/tests/cli/ext_integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn sablier_v2_core() {
4444
// Skip fork tests.
4545
.args(["--nmc", "Fork"])
4646
// Increase the gas limit: https://github.com/sablier-labs/v2-core/issues/956
47-
.args(["--gas-limit", u64::MAX.to_string().as_str()])
47+
.args(["--gas-limit", &u64::MAX.to_string()])
4848
// Run tests without optimizations.
4949
.env("FOUNDRY_PROFILE", "lite")
5050
.install_command(&["bun", "install", "--prefer-offline"])

crates/script/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ mod tests {
709709
"0x4e59b44847b379578588920ca78fbf26c0b4956c",
710710
"--unlocked",
711711
"--private-key",
712-
key.to_string().as_str(),
712+
&key.to_string(),
713713
]);
714714
assert!(args.is_err());
715715
}

crates/test-utils/src/script.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ impl ScriptTester {
158158

159159
/// Adds given address as sender
160160
pub fn sender(&mut self, addr: Address) -> &mut Self {
161-
self.args(&["--sender", addr.to_string().as_str()])
161+
self.args(&["--sender", &addr.to_string()])
162162
}
163163

164164
pub fn add_sig(&mut self, contract_name: &str, sig: &str) -> &mut Self {
165165
self.args(&["--tc", contract_name, "--sig", sig])
166166
}
167167

168168
pub fn add_create2_deployer(&mut self, create2_deployer: Address) -> &mut Self {
169-
self.args(&["--create2-deployer", create2_deployer.to_string().as_str()])
169+
self.args(&["--create2-deployer", &create2_deployer.to_string()])
170170
}
171171

172172
/// Adds the `--unlocked` flag

0 commit comments

Comments
 (0)