From f81adad8979444c818072e9f292b3d5e99234f4b Mon Sep 17 00:00:00 2001 From: Evan Rusmisel Date: Thu, 27 Mar 2025 12:38:36 -0700 Subject: [PATCH] rusty --- bin/src/daemon.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/src/daemon.rs b/bin/src/daemon.rs index 2ce836d..46523c6 100644 --- a/bin/src/daemon.rs +++ b/bin/src/daemon.rs @@ -162,13 +162,17 @@ fn update_ui(task_tracker: &TaskTracker, config: &config::Config, mut ui_shutdo task_tracker.spawn_blocking(move || { let mut fb: Framebuffer = Framebuffer::new(); - // this feels wrong, is there a more rusty way to do this? - let mut img: Option<&[u8]> = None; - if display_level == 2 { - img = Some(IMAGE_DIR.get_file("orca.gif").expect("failed to read orca.gif").contents()); - } else if display_level == 3 { - img = Some(IMAGE_DIR.get_file("eff.png").expect("failed to read eff.png").contents()); + let img = match display_level { + 2 => Some("orca.gif"), + 3 => Some("eff.png"), + _ => None, } + .map(|n| { + IMAGE_DIR + .get_file(n) + .expect(&format!("failed to read {n}")) + .contents() + }); loop { match ui_shutdown_rx.try_recv() { Ok(_) => {