Add generic parameters for manual impl assist

The `impl_trait` function takes an optional `GenericParamList` to create
the trait impl.
This commit is contained in:
TheDoctor314 2021-11-08 21:19:22 +05:30
parent 4f93fa1213
commit 05b368f065
2 changed files with 13 additions and 5 deletions

View file

@ -149,8 +149,13 @@ pub fn impl_(
ast_from_text(&format!("impl{} {}{} {{}}", params, ty, ty_params))
}
pub fn impl_trait(trait_: ast::Path, ty: ast::Path) -> ast::Impl {
ast_from_text(&format!("impl {} for {} {{}}", trait_, ty))
pub fn impl_trait(
trait_: ast::Path,
ty: ast::Path,
ty_params: Option<ast::GenericParamList>,
) -> ast::Impl {
let ty_params = ty_params.map_or_else(String::new, |params| params.to_string());
ast_from_text(&format!("impl{2} {} for {}{2} {{}}", trait_, ty, ty_params))
}
pub(crate) fn generic_arg_list() -> ast::GenericArgList {