allow try expr? when extacting function

This commit is contained in:
Vladyslav Katasonov 2021-02-10 19:26:42 +03:00
parent f345d1772a
commit 9eb19d92dd
2 changed files with 350 additions and 30 deletions

View file

@ -200,6 +200,9 @@ pub fn expr_return(expr: Option<ast::Expr>) -> ast::Expr {
None => expr_from_text("return"),
}
}
pub fn expr_try(expr: ast::Expr) -> ast::Expr {
expr_from_text(&format!("{}?", expr))
}
pub fn expr_match(expr: ast::Expr, match_arm_list: ast::MatchArmList) -> ast::Expr {
expr_from_text(&format!("match {} {}", expr, match_arm_list))
}