diff options
author | krk <[email protected]> | 2019-10-31 20:10:58 +0000 |
---|---|---|
committer | krk <[email protected]> | 2019-10-31 20:10:58 +0000 |
commit | 4a4d9f7a90dc0605992c4f774a8d9a1323ad6d1e (patch) | |
tree | e18fbba37ec5270c6fc740c0fc382fa08968cfcc /crates/ra_syntax/src/ast | |
parent | 998088876d91b7602068f8209a61918d4a8a8fe7 (diff) |
Handle IfLet in convert_to_guarded_return.
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 3d5f18bfa..979819d4b 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -110,6 +110,22 @@ pub fn match_arm_list(arms: impl Iterator<Item = ast::MatchArm>) -> ast::MatchAr | |||
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | pub fn let_match_early(expr: ast::Expr, early_expression: &str) -> ast::LetStmt { | ||
114 | return from_text(&format!( | ||
115 | r#"let {} = match {} {{ | ||
116 | Some(it) => it, | ||
117 | None => {}, | ||
118 | }};"#, | ||
119 | expr.syntax().text(), | ||
120 | expr.syntax().text(), | ||
121 | early_expression | ||
122 | )); | ||
123 | |||
124 | fn from_text(text: &str) -> ast::LetStmt { | ||
125 | ast_from_text(&format!("fn f() {{ {} }}", text)) | ||
126 | } | ||
127 | } | ||
128 | |||
113 | pub fn where_pred(path: ast::Path, bounds: impl Iterator<Item = ast::TypeBound>) -> ast::WherePred { | 129 | pub fn where_pred(path: ast::Path, bounds: impl Iterator<Item = ast::TypeBound>) -> ast::WherePred { |
114 | let bounds = bounds.map(|b| b.syntax().to_string()).join(" + "); | 130 | let bounds = bounds.map(|b| b.syntax().to_string()).join(" + "); |
115 | return from_text(&format!("{}: {}", path.syntax(), bounds)); | 131 | return from_text(&format!("{}: {}", path.syntax(), bounds)); |