Support generic function in generate_function assist
This commit is contained in:
@@ -823,6 +823,7 @@ pub fn fn_(
|
||||
visibility: Option<ast::Visibility>,
|
||||
fn_name: ast::Name,
|
||||
type_params: Option<ast::GenericParamList>,
|
||||
where_clause: Option<ast::WhereClause>,
|
||||
params: ast::ParamList,
|
||||
body: ast::BlockExpr,
|
||||
ret_type: Option<ast::RetType>,
|
||||
@@ -832,6 +833,10 @@ pub fn fn_(
|
||||
Some(type_params) => format!("{type_params}"),
|
||||
None => "".into(),
|
||||
};
|
||||
let where_clause = match where_clause {
|
||||
Some(it) => format!("{it} "),
|
||||
None => "".into(),
|
||||
};
|
||||
let ret_type = match ret_type {
|
||||
Some(ret_type) => format!("{ret_type} "),
|
||||
None => "".into(),
|
||||
@@ -844,7 +849,7 @@ pub fn fn_(
|
||||
let async_literal = if is_async { "async " } else { "" };
|
||||
|
||||
ast_from_text(&format!(
|
||||
"{visibility}{async_literal}fn {fn_name}{type_params}{params} {ret_type}{body}",
|
||||
"{visibility}{async_literal}fn {fn_name}{type_params}{params} {ret_type}{where_clause}{body}",
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user