Implement if_to_bool_then assist

This commit is contained in:
Lukas Wirth 2021-08-08 17:12:08 +02:00
parent f0d32591a6
commit 3b7c713af3
5 changed files with 386 additions and 5 deletions

View file

@ -56,6 +56,10 @@ impl ast::BlockExpr {
pub fn is_empty(&self) -> bool {
self.statements().next().is_none() && self.tail_expr().is_none()
}
pub fn as_lone_tail(&self) -> Option<ast::Expr> {
self.statements().next().is_none().then(|| self.tail_expr()).flatten()
}
}
impl ast::Pat {