fn restricted_event(&mut self, event: Event) {
        match event {
            // ESC was pressed. Cancels the game.
            Event::Key(KeyEvent { main_key: Key::Esc, .. }) => {
                self.state = State::Ended(EndKind::Cancel);
            },

            // Screen was resized. Propagates the new size.
            Event::Resize(event) => {
                if event.size.is_some() {
                    // If valid screen size, then we can keep the game running.
                    self.state = State::Running;
                }
            },

            // Other keys, ignores.
            Event::Key(_) => (),
        }
    }
/// Handles an event, but only to a restricted set of used events: resizing
/// or ESC.
Handles an event, but only to a restricted set of used events: resizing
or ESC.
Handles an event but only to a restricted set of used events : resizing or ESC .
fn restricted_event(&mut self, event: Event) {
        match event {
            // ESC was pressed. Cancels the game.
            Event::Key(KeyEvent { main_key: Key::Esc, .. }) => {
                self.state = State::Ended(EndKind::Cancel);
            },
            // Screen was resized. Propagates the new size.
            Event::Resize(event) => {
                if event.size.is_some() {
                    // If valid screen size, then we can keep the game running.
                    self.state = State::Running;
                }
            },
            // Other keys, ignores.
            Event::Key(_) => (),
        }
    }
fn restricted_event ( & mut self , event : Event ) { match event { // ESC was pressed. Cancels the game. Event :: Key ( KeyEvent { main_key : Key :: Esc , .. } ) => { self . state = State :: Ended ( EndKind :: Cancel ) ; } , // Screen was resized. Propagates the new size. Event :: Resize ( event ) => { if event . size . is_some ( ) { // If valid screen size, then we can keep the game running. self . state = State :: Running ; } } , // Other keys, ignores. Event :: Key ( _ ) => ( ) , } }
Handles an event, but only to a restricted set of used events: resizing
or ESC.
Handles an event but only to a restricted set of used events : resizing or ESC .
&mut self
event
Event
&mut self
event
Event