aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/make.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs
index 9781b748f..eef45090d 100644
--- a/crates/ra_syntax/src/ast/make.rs
+++ b/crates/ra_syntax/src/ast/make.rs
@@ -117,10 +117,11 @@ pub fn record_pat(path: ast::Path, pats: impl IntoIterator<Item = ast::Pat>) ->
117 } 117 }
118} 118}
119 119
120pub fn path_pat(path: ast::Path) -> ast::PathPat { 120/// Returns a `BindPat` if the path has just one segment, a `PathPat` otherwise.
121pub fn path_pat(path: ast::Path) -> ast::Pat {
121 let path_str = path.syntax().text().to_string(); 122 let path_str = path.syntax().text().to_string();
122 return from_text(path_str.as_str()); 123 return from_text(path_str.as_str());
123 fn from_text(text: &str) -> ast::PathPat { 124 fn from_text(text: &str) -> ast::Pat {
124 ast_from_text(&format!("fn f({}: ())", text)) 125 ast_from_text(&format!("fn f({}: ())", text))
125 } 126 }
126} 127}