fn full_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);
            },

            // Arrow up was pressed, with no modifiers. Changes direction to up.
            Event::Key(KeyEvent {
                main_key: Key::Up,
                shift: false,
                ctrl: false,
                alt: false,
            }) => {
                self.snake.change_direction(Direction::Up);
            },

            // Arrow down was pressed, with no modifiers. Changes direction to
            // down.
            Event::Key(KeyEvent {
                main_key: Key::Down,
                shift: false,
                ctrl: false,
                alt: false,
            }) => {
                self.snake.change_direction(Direction::Down);
            },

            // Arrow left was pressed, with no modifiers. Changes direction to
            // left.
            Event::Key(KeyEvent {
                main_key: Key::Left,
                shift: false,
                ctrl: false,
                alt: false,
            }) => {
                self.snake.change_direction(Direction::Left);
            },

            // Arrow right was pressed, with no modifiers. Changes direction to
            // right.
            Event::Key(KeyEvent {
                main_key: Key::Right,
                shift: false,
                ctrl: false,
                alt: false,
            }) => {
                self.snake.change_direction(Direction::Right);
            },

            // Screen was resized. Propagates the new size.
            Event::Resize(resize) => {
                self.resize(resize);
            },

            // Other keys, ignores.
            Event::Key(_) => (),
        }
    }
/// Handles an event, reacting to the full list of used events, be it
/// resizing or key pressing.
Handles an event, reacting to the full list of used events, be it
resizing or key pressing.
Handles an event reacting to the full list of used events be it resizing or key pressing .
fn full_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);
            },
            // Arrow up was pressed, with no modifiers. Changes direction to up.
            Event::Key(KeyEvent {
                main_key: Key::Up,
                shift: false,
                ctrl: false,
                alt: false,
            }) => {
                self.snake.change_direction(Direction::Up);
            },
            // Arrow down was pressed, with no modifiers. Changes direction to
            // down.
            Event::Key(KeyEvent {
                main_key: Key::Down,
                shift: false,
                ctrl: false,
                alt: false,
            }) => {
                self.snake.change_direction(Direction::Down);
            },
            // Arrow left was pressed, with no modifiers. Changes direction to
            // left.
            Event::Key(KeyEvent {
                main_key: Key::Left,
                shift: false,
                ctrl: false,
                alt: false,
            }) => {
                self.snake.change_direction(Direction::Left);
            },
            // Arrow right was pressed, with no modifiers. Changes direction to
            // right.
            Event::Key(KeyEvent {
                main_key: Key::Right,
                shift: false,
                ctrl: false,
                alt: false,
            }) => {
                self.snake.change_direction(Direction::Right);
            },
            // Screen was resized. Propagates the new size.
            Event::Resize(resize) => {
                self.resize(resize);
            },
            // Other keys, ignores.
            Event::Key(_) => (),
        }
    }
fn full_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 ) ; } , // Arrow up was pressed, with no modifiers. Changes direction to up. Event :: Key ( KeyEvent { main_key : Key :: Up , shift : false , ctrl : false , alt : false , } ) => { self . snake . change_direction ( Direction :: Up ) ; } , // Arrow down was pressed, with no modifiers. Changes direction to // down. Event :: Key ( KeyEvent { main_key : Key :: Down , shift : false , ctrl : false , alt : false , } ) => { self . snake . change_direction ( Direction :: Down ) ; } , // Arrow left was pressed, with no modifiers. Changes direction to // left. Event :: Key ( KeyEvent { main_key : Key :: Left , shift : false , ctrl : false , alt : false , } ) => { self . snake . change_direction ( Direction :: Left ) ; } , // Arrow right was pressed, with no modifiers. Changes direction to // right. Event :: Key ( KeyEvent { main_key : Key :: Right , shift : false , ctrl : false , alt : false , } ) => { self . snake . change_direction ( Direction :: Right ) ; } , // Screen was resized. Propagates the new size. Event :: Resize ( resize ) => { self . resize ( resize ) ; } , // Other keys, ignores. Event :: Key ( _ ) => ( ) , } }
Handles an event, reacting to the full list of used events, be it
resizing or key pressing.
Handles an event reacting to the full list of used events be it resizing or key pressing .
&mut self
event
Event
&mut self
event
Event