pprust: use as_deref

This commit is contained in:
Mazdak Farrokhzad 2020-01-22 01:38:05 +01:00
parent ce361fb24f
commit 7962ccb216

View File

@ -1643,7 +1643,7 @@ fn print_else(&mut self, els: Option<&ast::Expr>) {
self.print_expr_as_cond(i); self.print_expr_as_cond(i);
self.s.space(); self.s.space();
self.print_block(then); self.print_block(then);
self.print_else(e.as_ref().map(|e| &**e)) self.print_else(e.as_deref())
} }
// Final `else` block. // Final `else` block.
ast::ExprKind::Block(ref b, _) => { ast::ExprKind::Block(ref b, _) => {
@ -1947,7 +1947,7 @@ fn print_expr_outer_attr_style(&mut self, expr: &ast::Expr, is_inline: bool) {
self.print_let(pat, scrutinee); self.print_let(pat, scrutinee);
} }
ast::ExprKind::If(ref test, ref blk, ref elseopt) => { ast::ExprKind::If(ref test, ref blk, ref elseopt) => {
self.print_if(test, blk, elseopt.as_ref().map(|e| &**e)); self.print_if(test, blk, elseopt.as_deref())
} }
ast::ExprKind::While(ref test, ref blk, opt_label) => { ast::ExprKind::While(ref test, ref blk, opt_label) => {
if let Some(label) = opt_label { if let Some(label) = opt_label {