diff options
| author | Côme ALLART <come.allart@etu.emse.fr> | 2022-01-07 14:04:03 +0100 |
|---|---|---|
| committer | Côme ALLART <come.allart@etu.emse.fr> | 2022-01-07 14:07:35 +0100 |
| commit | 1b5c60f5491d8f992d89734e3027d5ba01fabfab (patch) | |
| tree | cf25b20839bad3d0a0b18422f2492d2edf3e7b9f | |
| parent | c2d3f908867335e393ac549a9e9c18d6c75f2996 (diff) | |
| download | rust-1b5c60f5491d8f992d89734e3027d5ba01fabfab.tar.gz rust-1b5c60f5491d8f992d89734e3027d5ba01fabfab.zip | |
refactor: apply suggestions
See PR #11194
| -rw-r--r-- | crates/ide_assists/src/handlers/generate_documentation_template.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crates/ide_assists/src/handlers/generate_documentation_template.rs b/crates/ide_assists/src/handlers/generate_documentation_template.rs index 97d1c2bd6d8..bb7c8b10102 100644 --- a/crates/ide_assists/src/handlers/generate_documentation_template.rs +++ b/crates/ide_assists/src/handlers/generate_documentation_template.rs @@ -229,15 +229,17 @@ fn self_type(ast_func: &ast::Fn) -> Option<ast::Type> { /// Output the real name of `Self` like `MyType<T>`, without the lifetimes. fn self_type_without_lifetimes(ast_func: &ast::Fn) -> Option<String> { - let path_segment = - ast::PathType::cast(self_type(ast_func)?.syntax().clone())?.path()?.segment()?; + let path_segment = match self_type(ast_func)? { + ast::Type::PathType(path_type) => path_type.path()?.segment()?, + _ => return None, + }; let mut name = path_segment.name_ref()?.to_string(); let generics = path_segment .generic_arg_list()? .generic_args() .filter(|generic| matches!(generic, ast::GenericArg::TypeArg(_))) .map(|generic| generic.to_string()); - let generics: String = Itertools::intersperse(generics, ", ".to_string()).collect(); + let generics: String = generics.format(", ").to_string(); if !generics.is_empty() { name.push('<'); name.push_str(&generics); @@ -325,7 +327,7 @@ fn arguments_from_params(param_list: &ast::ParamList) -> String { }, _ => "_".to_string(), }); - Itertools::intersperse(args_iter, ", ".to_string()).collect() + args_iter.format(", ").to_string() } /// Helper function to build a function call. `None` if expected `self_name` was not provided |
