From 9bdd556c9df9e4fd3b5f8d9f858603dafcd42795 Mon Sep 17 00:00:00 2001 From: electria Date: Thu, 30 Jul 2026 20:26:21 -0700 Subject: [PATCH] refactor: use newer helper method in State::new this should keep it from printing "no image to allocate" each time when started without an argument --- src/main.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 522e8c7..4de72f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,14 +30,14 @@ impl State { fn new() -> (Self, Task) { let mut state = State::default(); - state.error = env::args().nth(1).and_then(|path| { - utils::load_image(path) - .map(|image| state.image = Some(image)) - .err() - }); - let allocate_image = state.allocate_image(); + if let Some(path) = env::args().nth(1) { + match state.load_image(path) { + Err(e) => state.error = Some(e), + Ok(task) => return (state, task), + } + } - (state, allocate_image) + (state, Task::none()) } fn view(&self) -> Element<'_, Message, Theme, Renderer> { let mut main = Vec::new();