Skip to content

Commit 1b5c60f

Browse files
author
Côme ALLART
committed
refactor: apply suggestions
See PR #11194
1 parent c2d3f90 commit 1b5c60f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crates/ide_assists/src/handlers/generate_documentation_template.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,17 @@ fn self_type(ast_func: &ast::Fn) -> Option<ast::Type> {
229229

230230
/// Output the real name of `Self` like `MyType<T>`, without the lifetimes.
231231
fn self_type_without_lifetimes(ast_func: &ast::Fn) -> Option<String> {
232-
let path_segment =
233-
ast::PathType::cast(self_type(ast_func)?.syntax().clone())?.path()?.segment()?;
232+
let path_segment = match self_type(ast_func)? {
233+
ast::Type::PathType(path_type) => path_type.path()?.segment()?,
234+
_ => return None,
235+
};
234236
let mut name = path_segment.name_ref()?.to_string();
235237
let generics = path_segment
236238
.generic_arg_list()?
237239
.generic_args()
238240
.filter(|generic| matches!(generic, ast::GenericArg::TypeArg(_)))
239241
.map(|generic| generic.to_string());
240-
let generics: String = Itertools::intersperse(generics, ", ".to_string()).collect();
242+
let generics: String = generics.format(", ").to_string();
241243
if !generics.is_empty() {
242244
name.push('<');
243245
name.push_str(&generics);
@@ -325,7 +327,7 @@ fn arguments_from_params(param_list: &ast::ParamList) -> String {
325327
},
326328
_ => "_".to_string(),
327329
});
328-
Itertools::intersperse(args_iter, ", ".to_string()).collect()
330+
args_iter.format(", ").to_string()
329331
}
330332

331333
/// Helper function to build a function call. `None` if expected `self_name` was not provided

0 commit comments

Comments
 (0)