mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-22 11:24:24 +00:00
Initial implementation of the #5085 issue
This commit is contained in:
parent
74e7422b69
commit
fe3170dc34
4 changed files with 145 additions and 0 deletions
|
@ -294,6 +294,21 @@ pub fn param_list(pats: impl IntoIterator<Item = ast::Param>) -> ast::ParamList
|
|||
ast_from_text(&format!("fn f({}) {{ }}", args))
|
||||
}
|
||||
|
||||
pub fn generic_param(name: String, ty: Option<String>) -> ast::GenericParam {
|
||||
let bound = match ty {
|
||||
Some(it) => format!(": {}", it),
|
||||
None => String::new(),
|
||||
};
|
||||
ast_from_text(&format!("fn f<{}{}>() {{ }}", name, bound))
|
||||
}
|
||||
|
||||
pub fn generic_param_list(
|
||||
pats: impl IntoIterator<Item = ast::GenericParam>,
|
||||
) -> ast::GenericParamList {
|
||||
let args = pats.into_iter().join(", ");
|
||||
ast_from_text(&format!("fn f<{}>() {{ }}", args))
|
||||
}
|
||||
|
||||
pub fn visibility_pub_crate() -> ast::Visibility {
|
||||
ast_from_text("pub(crate) struct S")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue