Skip to content

Commit 91ea972

Browse files
committed
Take &str instead of String in argument fn
1 parent 59c1b2a commit 91ea972

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/cli-support/src/js/js2rust.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
8585
{
8686
if let Some(arg_names) = opt_arg_names.into() {
8787
for (arg, arg_name) in function.arguments.iter().zip(arg_names) {
88-
self.argument(arg, arg_name.clone())?;
88+
self.argument(arg, arg_name.as_str())?;
8989
}
9090
} else {
9191
for arg in function.arguments.iter() {
@@ -151,19 +151,19 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
151151
self
152152
}
153153

154-
fn abi_arg(&mut self, opt_arg_name: Option<String>) -> String {
154+
fn abi_arg(&mut self, opt_arg_name: Option<&str>) -> String {
155155
let ret = if let Some(x) = opt_arg_name {
156-
x
156+
x.into()
157157
} else {
158158
format!("arg{}", self.arg_idx)
159159
};
160160
self.arg_idx += 1;
161161
ret
162162
}
163163

164-
pub fn argument<I>(&mut self, arg: &Descriptor, opt_arg_name: I) -> Result<&mut Self, Error>
164+
pub fn argument<'c, I>(&mut self, arg: &Descriptor, opt_arg_name: I) -> Result<&mut Self, Error>
165165
where
166-
I: Into<Option<String>>,
166+
I: Into<Option<&'c str>>,
167167
{
168168
let i = self.arg_idx;
169169
let name = self.abi_arg(opt_arg_name.into());

0 commit comments

Comments
 (0)