mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-19 01:50:32 +00:00
Support generic function in generate_function
assist
This commit is contained in:
parent
32955c30cd
commit
3edde6fcc1
5 changed files with 888 additions and 45 deletions
|
@ -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}",
|
||||
))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue