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
This commit is contained in:
electria 2026-07-30 20:26:21 -07:00
commit 9bdd556c9d
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -30,14 +30,14 @@ impl State {
fn new() -> (Self, Task<Message>) { fn new() -> (Self, Task<Message>) {
let mut state = State::default(); let mut state = State::default();
state.error = env::args().nth(1).and_then(|path| { if let Some(path) = env::args().nth(1) {
utils::load_image(path) match state.load_image(path) {
.map(|image| state.image = Some(image)) Err(e) => state.error = Some(e),
.err() Ok(task) => return (state, task),
}); }
let allocate_image = state.allocate_image(); }
(state, allocate_image) (state, Task::none())
} }
fn view(&self) -> Element<'_, Message, Theme, Renderer> { fn view(&self) -> Element<'_, Message, Theme, Renderer> {
let mut main = Vec::new(); let mut main = Vec::new();