From a91cc6b525b11a41a05b3fcf2a5c5aef428d9bfb Mon Sep 17 00:00:00 2001 From: electria Date: Mon, 27 Jul 2026 21:42:52 -0700 Subject: [PATCH] refactor: apply clippy lints --- src/main.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 62f5087..3d8618d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -118,18 +118,15 @@ impl State { _ => {} }, - Message::Event(iced::Event::Window(window_event)) => match window_event { - window::Event::FileDropped(file) => match self.load_image(file) { + Message::Event(iced::Event::Window(window::Event::FileDropped(file))) => { + match self.load_image(file) { Ok(task) => { self.error = None; return task; } Err(e) => self.error = Some(e), - }, - - // ignore unused window events - _ => {} - }, + } + } // ignore unused events Message::Event(_) => {} @@ -139,9 +136,9 @@ impl State { } fn load_image(&mut self, path: impl AsRef) -> Result, String> { - utils::load_image(path).and_then(|image| { + utils::load_image(path).map(|image| { self.image = Some(image); - Ok(self.allocate_image()) + self.allocate_image() }) } fn pick_and_load_image(&mut self) -> Result, String> { @@ -152,7 +149,6 @@ impl State { self.error = utils::save_image(self.image.as_ref()).err(); } - #[must_use] fn allocate_image(&self) -> Task { let Some(image) = self.image.as_ref() else { eprintln!("no image to allocate"); @@ -173,7 +169,7 @@ impl State { fn title(&self) -> String { match self.image.as_ref() { Some(image) => format!("imagey {}x{}", image.width(), image.height()), - None => format!("imagey"), + None => "imagey".into(), } } }