From 7d7417bf14eb3ae0f635f7194982cd96d2f9796c Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Thu, 21 Dec 2023 11:39:25 -0500 Subject: [PATCH] clippy::blocks_in_conditions warning: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let` --> src/cmd/count.rs:60:49 | 60 | match conf.indexed().unwrap_or_else(|_| { | _________________________________________________^ 61 | | info!("index is stale"); 62 | | None 63 | | }) { | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_conditions = note: `#[warn(clippy::blocks_in_conditions)]` on by default --- src/cmd/count.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cmd/count.rs b/src/cmd/count.rs index 78bb13140..8f2e30e75 100644 --- a/src/cmd/count.rs +++ b/src/cmd/count.rs @@ -57,10 +57,11 @@ pub fn run(argv: &[&str]) -> CliResult<()> { let (count, width) = if args.flag_width { count_input(&conf, args.flag_width)? } else { - match conf.indexed().unwrap_or_else(|_| { + let index_status = conf.indexed().unwrap_or_else(|_| { info!("index is stale"); None - }) { + }); + match index_status { Some(idx) => { info!("index used"); (idx.count(), 0)