refactor: apply clippy lints
This commit is contained in:
parent
c4738ad2c8
commit
a91cc6b525
1 changed files with 7 additions and 11 deletions
18
src/main.rs
18
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<Path>) -> Result<Task<Message>, 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<Task<Message>, String> {
|
||||
|
|
@ -152,7 +149,6 @@ impl State {
|
|||
self.error = utils::save_image(self.image.as_ref()).err();
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
fn allocate_image(&self) -> Task<Message> {
|
||||
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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue