From 1fde6642082ece4b6c64e29f2983e0f988ce2b59 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Fri, 27 Jun 2025 17:39:42 +0100 Subject: Reduce nesting depth --- src/main.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 266e915..bc9a7b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,17 +79,18 @@ async fn main() -> anyhow::Result<()> { match notification? { Incoming(Packet::Publish(p)) => { for (topic, programs) in conf.routes.iter() { - if topic_match(&topic, &p.topic) { - for program in programs { - // TODO: Switch to moro_local to avoid this ewwyness - let program = program.clone(); - let p = p.clone(); - tokio::spawn(async move { - if let Err(e) = run(&program, &p).await { - eprintln!("error: Failed to run {program:?}: {e:?}"); - } - }); - } + if !topic_match(&topic, &p.topic) { + continue; + } + for program in programs { + // TODO: Switch to moro_local to avoid this ewwyness + let program = program.clone(); + let p = p.clone(); + tokio::spawn(async move { + if let Err(e) = run(&program, &p).await { + eprintln!("error: Failed to run {program:?}: {e:?}"); + } + }); } } } -- cgit v1.2.3-70-g09d2