assists: turn while into loop

This commit is contained in:
Andrzej Głuszak 2021-09-16 15:36:44 +02:00
parent 726a2aa211
commit 11a56f886b
4 changed files with 220 additions and 0 deletions

View file

@ -316,6 +316,11 @@ pub fn expr_if(
pub fn expr_for_loop(pat: ast::Pat, expr: ast::Expr, block: ast::BlockExpr) -> ast::Expr {
expr_from_text(&format!("for {} in {} {}", pat, expr, block))
}
pub fn expr_loop(block: ast::BlockExpr) -> ast::Expr {
expr_from_text(&format!("loop {}", block))
}
pub fn expr_prefix(op: SyntaxKind, expr: ast::Expr) -> ast::Expr {
let token = token(op);
expr_from_text(&format!("{}{}", token, expr))