Simple fix for make::impl_trait

This commit is contained in:
alibektas 2023-04-17 00:41:08 +03:00
parent a6464392c1
commit 4601331ceb

View File

@ -184,8 +184,11 @@ pub fn impl_trait(
ty: ast::Path, ty: ast::Path,
ty_params: Option<ast::GenericParamList>, ty_params: Option<ast::GenericParamList>,
) -> ast::Impl { ) -> ast::Impl {
let ty_params = ty_params.map_or_else(String::new, |params| params.to_string()); // TODO : If this function is now correct we can also change `impl_` accordingly`
ast_from_text(&format!("impl{ty_params} {trait_} for {ty}{ty_params} {{}}")) let ty_params_str = ty_params.as_ref().map_or_else(String::new, |params| params.to_string());
let ty_genargs_str =
ty_params.map_or_else(String::new, |params| params.to_generic_args().to_string());
ast_from_text(&format!("impl{ty_params_str} {trait_} for {ty}{ty_genargs_str} {{}}"))
} }
pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment { pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment {