aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/handlers/add_custom_impl.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-08-12 14:06:38 +0100
committerGitHub <[email protected]>2020-08-12 14:06:38 +0100
commit2d41cc0ea323e3c4d97300e4d66de11d6b7148ef (patch)
treea7b048b0d394fa48e6c9ccf08947cbb52a87ab9d /crates/ra_assists/src/handlers/add_custom_impl.rs
parent441fbe3b0aff2e6b141912d18f22ee5866b38516 (diff)
parent1c359ab634edb81b51e3c7eadfb83d46c926e890 (diff)
Merge #5722
5722: Replace SepBy with Itertools r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/handlers/add_custom_impl.rs')
-rw-r--r--crates/ra_assists/src/handlers/add_custom_impl.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs
index b67438b6b..ebdf00e67 100644
--- a/crates/ra_assists/src/handlers/add_custom_impl.rs
+++ b/crates/ra_assists/src/handlers/add_custom_impl.rs
@@ -1,10 +1,10 @@
1use itertools::Itertools;
1use ra_syntax::{ 2use ra_syntax::{
2 ast::{self, AstNode}, 3 ast::{self, AstNode},
3 Direction, SmolStr, 4 Direction, SmolStr,
4 SyntaxKind::{IDENT, WHITESPACE}, 5 SyntaxKind::{IDENT, WHITESPACE},
5 TextRange, TextSize, 6 TextRange, TextSize,
6}; 7};
7use stdx::SepBy;
8 8
9use crate::{ 9use crate::{
10 assist_context::{AssistContext, Assists}, 10 assist_context::{AssistContext, Assists},
@@ -61,9 +61,9 @@ pub(crate) fn add_custom_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<
61 .filter(|t| t != trait_token.text()) 61 .filter(|t| t != trait_token.text())
62 .collect::<Vec<SmolStr>>(); 62 .collect::<Vec<SmolStr>>();
63 let has_more_derives = !new_attr_input.is_empty(); 63 let has_more_derives = !new_attr_input.is_empty();
64 let new_attr_input = new_attr_input.iter().sep_by(", ").surround_with("(", ")").to_string();
65 64
66 if has_more_derives { 65 if has_more_derives {
66 let new_attr_input = format!("({})", new_attr_input.iter().format(", "));
67 builder.replace(input.syntax().text_range(), new_attr_input); 67 builder.replace(input.syntax().text_range(), new_attr_input);
68 } else { 68 } else {
69 let attr_range = attr.syntax().text_range(); 69 let attr_range = attr.syntax().text_range();