Initial implementation of the #5085 issue

This commit is contained in:
Aleksei Sidorov 2020-09-03 01:32:18 +03:00
parent 74e7422b69
commit fe3170dc34
4 changed files with 145 additions and 0 deletions

View file

@ -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")
}