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:
parent
7ce87e2870
commit
9bdd556c9d
1 changed files with 7 additions and 7 deletions
14
src/main.rs
14
src/main.rs
|
|
@ -30,14 +30,14 @@ impl State {
|
|||
fn new() -> (Self, Task<Message>) {
|
||||
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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue