Update function

The only remaining required method of the Widget trait is update(). In this method, we'll manage the Quit message:

#[widget]
impl Widget for App {
    fn update(&mut self, event: Msg) {
        match event {
            Quit => gtk::main_quit(),
        }
    }

    // …
}

Here, we specify that when we receive the Quit message, we call gtk::main_quit(), which is a function similar to Application::quit() that we used in Chapter 5, Creating a Music Player.

It should be noted that the #[widget] attribute will also generate the App structure that will contain the widgets and the model.

We can finally show this window by calling its run() method in the main function:

fn main() {
    App::run(()).unwrap();
}

Later, we'll see why we need to specify () as a parameter to run().