refactor: apply clippy lints

This commit is contained in:
electria 2026-07-27 21:42:52 -07:00
commit a91cc6b525
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -118,18 +118,15 @@ impl State {
_ => {} _ => {}
}, },
Message::Event(iced::Event::Window(window_event)) => match window_event { Message::Event(iced::Event::Window(window::Event::FileDropped(file))) => {
window::Event::FileDropped(file) => match self.load_image(file) { match self.load_image(file) {
Ok(task) => { Ok(task) => {
self.error = None; self.error = None;
return task; return task;
} }
Err(e) => self.error = Some(e), Err(e) => self.error = Some(e),
}, }
}
// ignore unused window events
_ => {}
},
// ignore unused events // ignore unused events
Message::Event(_) => {} Message::Event(_) => {}
@ -139,9 +136,9 @@ impl State {
} }
fn load_image(&mut self, path: impl AsRef<Path>) -> Result<Task<Message>, String> { fn load_image(&mut self, path: impl AsRef<Path>) -> Result<Task<Message>, String> {
utils::load_image(path).and_then(|image| { utils::load_image(path).map(|image| {
self.image = Some(image); self.image = Some(image);
Ok(self.allocate_image()) self.allocate_image()
}) })
} }
fn pick_and_load_image(&mut self) -> Result<Task<Message>, String> { fn pick_and_load_image(&mut self) -> Result<Task<Message>, String> {
@ -152,7 +149,6 @@ impl State {
self.error = utils::save_image(self.image.as_ref()).err(); self.error = utils::save_image(self.image.as_ref()).err();
} }
#[must_use]
fn allocate_image(&self) -> Task<Message> { fn allocate_image(&self) -> Task<Message> {
let Some(image) = self.image.as_ref() else { let Some(image) = self.image.as_ref() else {
eprintln!("no image to allocate"); eprintln!("no image to allocate");
@ -173,7 +169,7 @@ impl State {
fn title(&self) -> String { fn title(&self) -> String {
match self.image.as_ref() { match self.image.as_ref() {
Some(image) => format!("imagey {}x{}", image.width(), image.height()), Some(image) => format!("imagey {}x{}", image.width(), image.height()),
None => format!("imagey"), None => "imagey".into(),
} }
} }
} }