Skip to content

Commit 80a6868

Browse files
author
Côme ALLART
committed
refactor: use Itertools::intersperse
1 parent 7266fdb commit 80a6868

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

crates/ide_assists/src/handlers/generate_documentation_template.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use hir::{AsAssocItem, HasVisibility, ModuleDef, Visibility};
22
use ide_db::assists::{AssistId, AssistKind};
3+
use itertools::Itertools;
34
use stdx::to_lower_snake_case;
45
use syntax::{
56
ast::{self, edit::IndentLevel, HasDocComments, HasName},
@@ -354,7 +355,7 @@ fn arguments_from_params(param_list: &ast::ParamList) -> String {
354355
},
355356
_ => "_".to_string(),
356357
});
357-
intersperse_string(args_iter, ", ")
358+
Itertools::intersperse(args_iter, ", ".to_string()).collect()
358359
}
359360

360361
/// 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 {
430431
}
431432
}
432433

433-
/// Helper function to concatenate string with a separator between them
434-
fn intersperse_string(mut iter: impl Iterator<Item = String>, separator: &str) -> String {
435-
let mut result = String::new();
436-
if let Some(first) = iter.next() {
437-
result.push_str(&first);
438-
}
439-
for string in iter {
440-
result.push_str(separator);
441-
result.push_str(&string);
442-
}
443-
result
444-
}
445-
446434
#[cfg(test)]
447435
mod tests {
448436
use crate::tests::{check_assist, check_assist_not_applicable};

0 commit comments

Comments
 (0)