Revise treatment of name parameter.

This commit is contained in:
Stephen Chung
2020-08-16 18:24:42 +08:00
parent 7eb75f6790
commit 31a05f8c48
3 changed files with 22 additions and 32 deletions

View File

@@ -29,8 +29,12 @@ pub(crate) fn generate_body(
&format!("{}_token", function.name().to_string()),
function.name().span(),
);
let fn_literal =
syn::LitStr::new(&function.name().to_string(), proc_macro2::Span::call_site());
let reg_name = if let Some(ref name) = function.params.name {
name.clone()
} else {
function.name().to_string()
};
let fn_literal = syn::LitStr::new(&reg_name, proc_macro2::Span::call_site());
let fn_input_types: Vec<syn::Expr> = function
.arg_list()
.map(|fnarg| match fnarg {