From 93aa5b31b5f5ce1dd1304ce29bb15ced46a94a77 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 21 Oct 2023 21:44:23 -0700 Subject: [PATCH] Resolve get_first clippy lint warning: accessing first element with `block.stmts.get(0)` --> src/expr.rs:915:20 | 915 | match (block.stmts.get(0), block.stmts.get(1)) { | ^^^^^^^^^^^^^^^^^^ help: try: `block.stmts.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first = note: `-W clippy::get-first` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::get_first)]` --- src/expr.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index 3be3004..040d896 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -912,8 +912,8 @@ impl Printer { if attr::has_inner(attrs) || !block.stmts.is_empty() { self.space(); self.inner_attrs(attrs); - match (block.stmts.get(0), block.stmts.get(1)) { - (Some(Stmt::Expr(expr, None)), None) if stmt::break_after(expr) => { + match block.stmts.as_slice() { + [Stmt::Expr(expr, None)] if stmt::break_after(expr) => { self.ibox(0); self.expr_beginning_of_line(expr, true); self.end();