aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/make.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 9f6f1cc53..9257ccd1a 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -136,6 +136,20 @@ pub fn placeholder_pat() -> ast::PlaceholderPat {
136 } 136 }
137} 137}
138 138
139/// Creates a tuple of patterns from an interator of patterns.
140///
141/// Invariant: `pats` must be length > 1
142///
143/// FIXME handle `pats` length == 1
144pub fn tuple_pat(pats: impl IntoIterator<Item = ast::Pat>) -> ast::TuplePat {
145 let pats_str = pats.into_iter().map(|p| p.to_string()).join(", ");
146 return from_text(&format!("({})", pats_str));
147
148 fn from_text(text: &str) -> ast::TuplePat {
149 ast_from_text(&format!("fn f({}: ())", text))
150 }
151}
152
139pub fn tuple_struct_pat( 153pub fn tuple_struct_pat(
140 path: ast::Path, 154 path: ast::Path,
141 pats: impl IntoIterator<Item = ast::Pat>, 155 pats: impl IntoIterator<Item = ast::Pat>,