diff options
| author | Côme ALLART <come.allart@etu.emse.fr> | 2021-12-11 20:41:23 +0100 |
|---|---|---|
| committer | Côme ALLART <come.allart@etu.emse.fr> | 2021-12-11 20:41:23 +0100 |
| commit | 80a68685db6914d05cda7c7ae05a87721c4d467d (patch) | |
| tree | 277238b565799dd37a0436487cf6513443ca3b0c | |
| parent | 7266fdb5a400170563622da48ec1b2d1b524c7c3 (diff) | |
| download | rust-80a68685db6914d05cda7c7ae05a87721c4d467d.tar.gz rust-80a68685db6914d05cda7c7ae05a87721c4d467d.zip | |
refactor: use Itertools::intersperse
| -rw-r--r-- | crates/ide_assists/src/handlers/generate_documentation_template.rs | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/crates/ide_assists/src/handlers/generate_documentation_template.rs b/crates/ide_assists/src/handlers/generate_documentation_template.rs index 5205a8ac7ed..a2fe3463b6f 100644 --- a/crates/ide_assists/src/handlers/generate_documentation_template.rs +++ b/crates/ide_assists/src/handlers/generate_documentation_template.rs @@ -1,5 +1,6 @@ use hir::{AsAssocItem, HasVisibility, ModuleDef, Visibility}; use ide_db::assists::{AssistId, AssistKind}; +use itertools::Itertools; use stdx::to_lower_snake_case; use syntax::{ ast::{self, edit::IndentLevel, HasDocComments, HasName}, @@ -354,7 +355,7 @@ fn arguments_from_params(param_list: &ast::ParamList) -> String { }, _ => "_".to_string(), }); - intersperse_string(args_iter, ", ") + Itertools::intersperse(args_iter, ", ".to_string()).collect() } /// Helper function to build a function call. `None` if expected `self_name` was not provided @@ -430,19 +431,6 @@ fn returns_a_value(ast_func: &ast::Fn) -> bool { } } -/// Helper function to concatenate string with a separator between them -fn intersperse_string(mut iter: impl Iterator<Item = String>, separator: &str) -> String { - let mut result = String::new(); - if let Some(first) = iter.next() { - result.push_str(&first); - } - for string in iter { - result.push_str(separator); - result.push_str(&string); - } - result -} - #[cfg(test)] mod tests { use crate::tests::{check_assist, check_assist_not_applicable}; |
