From 91ea972c030781a0120085b22d165631b2f50753 Mon Sep 17 00:00:00 2001 From: Caio Date: Thu, 14 Mar 2019 12:21:41 -0300 Subject: [PATCH] Take &str instead of String in argument fn --- crates/cli-support/src/js/js2rust.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/cli-support/src/js/js2rust.rs b/crates/cli-support/src/js/js2rust.rs index e5b7e113..1b25307a 100644 --- a/crates/cli-support/src/js/js2rust.rs +++ b/crates/cli-support/src/js/js2rust.rs @@ -85,7 +85,7 @@ impl<'a, 'b> Js2Rust<'a, 'b> { { if let Some(arg_names) = opt_arg_names.into() { for (arg, arg_name) in function.arguments.iter().zip(arg_names) { - self.argument(arg, arg_name.clone())?; + self.argument(arg, arg_name.as_str())?; } } else { for arg in function.arguments.iter() { @@ -151,9 +151,9 @@ impl<'a, 'b> Js2Rust<'a, 'b> { self } - fn abi_arg(&mut self, opt_arg_name: Option) -> String { + fn abi_arg(&mut self, opt_arg_name: Option<&str>) -> String { let ret = if let Some(x) = opt_arg_name { - x + x.into() } else { format!("arg{}", self.arg_idx) }; @@ -161,9 +161,9 @@ impl<'a, 'b> Js2Rust<'a, 'b> { ret } - pub fn argument(&mut self, arg: &Descriptor, opt_arg_name: I) -> Result<&mut Self, Error> + pub fn argument<'c, I>(&mut self, arg: &Descriptor, opt_arg_name: I) -> Result<&mut Self, Error> where - I: Into>, + I: Into>, { let i = self.arg_idx; let name = self.abi_arg(opt_arg_name.into());