aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_syntax/src/ast/edit.rs2
-rw-r--r--crates/ra_syntax/src/ast/make.rs19
2 files changed, 12 insertions, 9 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index 47bdbb81a..6f005a2d8 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -358,7 +358,7 @@ fn replace_children<N: AstNode>(
358fn test_increase_indent() { 358fn test_increase_indent() {
359 let arm_list = { 359 let arm_list = {
360 let arm = make::match_arm(iter::once(make::placeholder_pat().into()), make::expr_unit()); 360 let arm = make::match_arm(iter::once(make::placeholder_pat().into()), make::expr_unit());
361 make::match_arm_list(vec![arm.clone(), arm].into_iter()) 361 make::match_arm_list(vec![arm.clone(), arm])
362 }; 362 };
363 assert_eq!( 363 assert_eq!(
364 arm_list.syntax().to_string(), 364 arm_list.syntax().to_string(),
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 6c903ca64..9749327fa 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -84,9 +84,9 @@ pub fn placeholder_pat() -> ast::PlaceholderPat {
84 84
85pub fn tuple_struct_pat( 85pub fn tuple_struct_pat(
86 path: ast::Path, 86 path: ast::Path,
87 pats: impl Iterator<Item = ast::Pat>, 87 pats: impl IntoIterator<Item = ast::Pat>,
88) -> ast::TupleStructPat { 88) -> ast::TupleStructPat {
89 let pats_str = pats.map(|p| p.syntax().to_string()).join(", "); 89 let pats_str = pats.into_iter().map(|p| p.syntax().to_string()).join(", ");
90 return from_text(&format!("{}({})", path.syntax(), pats_str)); 90 return from_text(&format!("{}({})", path.syntax(), pats_str));
91 91
92 fn from_text(text: &str) -> ast::TupleStructPat { 92 fn from_text(text: &str) -> ast::TupleStructPat {
@@ -94,8 +94,8 @@ pub fn tuple_struct_pat(
94 } 94 }
95} 95}
96 96
97pub fn record_pat(path: ast::Path, pats: impl Iterator<Item = ast::Pat>) -> ast::RecordPat { 97pub fn record_pat(path: ast::Path, pats: impl IntoIterator<Item = ast::Pat>) -> ast::RecordPat {
98 let pats_str = pats.map(|p| p.syntax().to_string()).join(", "); 98 let pats_str = pats.into_iter().map(|p| p.syntax().to_string()).join(", ");
99 return from_text(&format!("{} {{ {} }}", path.syntax(), pats_str)); 99 return from_text(&format!("{} {{ {} }}", path.syntax(), pats_str));
100 100
101 fn from_text(text: &str) -> ast::RecordPat { 101 fn from_text(text: &str) -> ast::RecordPat {
@@ -129,8 +129,11 @@ pub fn match_arm_list(arms: impl IntoIterator<Item = ast::MatchArm>) -> ast::Mat
129 } 129 }
130} 130}
131 131
132pub fn where_pred(path: ast::Path, bounds: impl Iterator<Item = ast::TypeBound>) -> ast::WherePred { 132pub fn where_pred(
133 let bounds = bounds.map(|b| b.syntax().to_string()).join(" + "); 133 path: ast::Path,
134 bounds: impl IntoIterator<Item = ast::TypeBound>,
135) -> ast::WherePred {
136 let bounds = bounds.into_iter().map(|b| b.syntax().to_string()).join(" + ");
134 return from_text(&format!("{}: {}", path.syntax(), bounds)); 137 return from_text(&format!("{}: {}", path.syntax(), bounds));
135 138
136 fn from_text(text: &str) -> ast::WherePred { 139 fn from_text(text: &str) -> ast::WherePred {
@@ -138,8 +141,8 @@ pub fn where_pred(path: ast::Path, bounds: impl Iterator<Item = ast::TypeBound>)
138 } 141 }
139} 142}
140 143
141pub fn where_clause(preds: impl Iterator<Item = ast::WherePred>) -> ast::WhereClause { 144pub fn where_clause(preds: impl IntoIterator<Item = ast::WherePred>) -> ast::WhereClause {
142 let preds = preds.map(|p| p.syntax().to_string()).join(", "); 145 let preds = preds.into_iter().map(|p| p.syntax().to_string()).join(", ");
143 return from_text(preds.as_str()); 146 return from_text(preds.as_str());
144 147
145 fn from_text(text: &str) -> ast::WhereClause { 148 fn from_text(text: &str) -> ast::WhereClause {