unsafe fn move_state_to(&self, new_runner_state: RunnerState) {
        use RunnerState::{
            Destroyed, HandlingMainEvents, HandlingRedrawEvents, Idle, Uninitialized,
        };

        match (
            self.runner_state.replace(new_runner_state),
            new_runner_state,
        ) {
            (Uninitialized, Uninitialized)
            | (Idle, Idle)
            | (HandlingMainEvents, HandlingMainEvents)
            | (HandlingRedrawEvents, HandlingRedrawEvents)
            | (Destroyed, Destroyed) => (),

            // State transitions that initialize the event loop.
            (Uninitialized, HandlingMainEvents) => {
                self.call_new_events(true);
            }
            (Uninitialized, HandlingRedrawEvents) => {
                self.call_new_events(true);
                self.call_event_handler(Event::MainEventsCleared);
            }
            (Uninitialized, Idle) => {
                self.call_new_events(true);
                self.call_event_handler(Event::MainEventsCleared);
                self.call_redraw_events_cleared();
            }
            (Uninitialized, Destroyed) => {
                self.call_new_events(true);
                self.call_event_handler(Event::MainEventsCleared);
                self.call_redraw_events_cleared();
                self.call_event_handler(Event::LoopDestroyed);
            }
            (_, Uninitialized) => panic!("cannot move state to Uninitialized"),

            // State transitions that start the event handling process.
            (Idle, HandlingMainEvents) => {
                self.call_new_events(false);
            }
            (Idle, HandlingRedrawEvents) => {
                self.call_new_events(false);
                self.call_event_handler(Event::MainEventsCleared);
            }
            (Idle, Destroyed) => {
                self.call_event_handler(Event::LoopDestroyed);
            }

            (HandlingMainEvents, HandlingRedrawEvents) => {
                self.call_event_handler(Event::MainEventsCleared);
            }
            (HandlingMainEvents, Idle) => {
                warn!("RedrawEventsCleared emitted without explicit MainEventsCleared");
                self.call_event_handler(Event::MainEventsCleared);
                self.call_redraw_events_cleared();
            }
            (HandlingMainEvents, Destroyed) => {
                self.call_event_handler(Event::MainEventsCleared);
                self.call_redraw_events_cleared();
                self.call_event_handler(Event::LoopDestroyed);
            }

            (HandlingRedrawEvents, Idle) => {
                self.call_redraw_events_cleared();
            }
            (HandlingRedrawEvents, HandlingMainEvents) => {
                warn!("NewEvents emitted without explicit RedrawEventsCleared");
                self.call_redraw_events_cleared();
                self.call_new_events(false);
            }
            (HandlingRedrawEvents, Destroyed) => {
                self.call_redraw_events_cleared();
                self.call_event_handler(Event::LoopDestroyed);
            }

            (Destroyed, _) => panic!("cannot move state from Destroyed"),
        }
    }
/// Dispatch control flow events (`NewEvents`, `MainEventsCleared`, `RedrawEventsCleared`, and
/// `LoopDestroyed`) as necessary to bring the internal `RunnerState` to the new runner state.
///
/// The state transitions are defined as follows:
///
/// ```text
///    Uninitialized
///          |
///          V
///  HandlingMainEvents
///   ^            |
///   |            V
/// Idle <--- HandlingRedrawEvents
///   |
///   V
/// Destroyed
/// ```
///
/// Attempting to transition back to `Uninitialized` will result in a panic. Attempting to
/// transition *from* `Destroyed` will also reuslt in a panic. Transitioning to the current
/// state is a no-op. Even if the `new_runner_state` isn't the immediate next state in the
/// runner state machine (e.g. `self.runner_state == HandlingMainEvents` and
/// `new_runner_state == Idle`), the intermediate state transitions will still be executed.


The state transitions are defined as follows.



Attempting to transition back to `Uninitialized` will result in a panic. Attempting to
transition *from* `Destroyed` will also reuslt in a panic. Transitioning to the current
state is a no-op. Even if the `new_runner_state` isn't the immediate next state in the
runner state machine , the intermediate state transitions will still be executed.
The state transitions are defined as follows . Attempting to transition back to ` Uninitialized ` will result in a panic . Attempting to transition * from * ` Destroyed ` will also reuslt in a panic . Transitioning to the current state is a no - op . Even if the ` new_runner_state ` isn ' t the immediate next state in the runner state machine the intermediate state transitions will still be executed .
unsafe fn move_state_to(&self, new_runner_state: RunnerState) {
        use RunnerState::{
            Destroyed, HandlingMainEvents, HandlingRedrawEvents, Idle, Uninitialized,
        };
        match (
            self.runner_state.replace(new_runner_state),
            new_runner_state,
        ) {
            (Uninitialized, Uninitialized)
            | (Idle, Idle)
            | (HandlingMainEvents, HandlingMainEvents)
            | (HandlingRedrawEvents, HandlingRedrawEvents)
            | (Destroyed, Destroyed) => (),
            // State transitions that initialize the event loop.
            (Uninitialized, HandlingMainEvents) => {
                self.call_new_events(true);
            }
            (Uninitialized, HandlingRedrawEvents) => {
                self.call_new_events(true);
                self.call_event_handler(Event::MainEventsCleared);
            }
            (Uninitialized, Idle) => {
                self.call_new_events(true);
                self.call_event_handler(Event::MainEventsCleared);
                self.call_redraw_events_cleared();
            }
            (Uninitialized, Destroyed) => {
                self.call_new_events(true);
                self.call_event_handler(Event::MainEventsCleared);
                self.call_redraw_events_cleared();
                self.call_event_handler(Event::LoopDestroyed);
            }
            (_, Uninitialized) => panic!("cannot move state to Uninitialized"),
            // State transitions that start the event handling process.
            (Idle, HandlingMainEvents) => {
                self.call_new_events(false);
            }
            (Idle, HandlingRedrawEvents) => {
                self.call_new_events(false);
                self.call_event_handler(Event::MainEventsCleared);
            }
            (Idle, Destroyed) => {
                self.call_event_handler(Event::LoopDestroyed);
            }
            (HandlingMainEvents, HandlingRedrawEvents) => {
                self.call_event_handler(Event::MainEventsCleared);
            }
            (HandlingMainEvents, Idle) => {
                warn!("RedrawEventsCleared emitted without explicit MainEventsCleared");
                self.call_event_handler(Event::MainEventsCleared);
                self.call_redraw_events_cleared();
            }
            (HandlingMainEvents, Destroyed) => {
                self.call_event_handler(Event::MainEventsCleared);
                self.call_redraw_events_cleared();
                self.call_event_handler(Event::LoopDestroyed);
            }
            (HandlingRedrawEvents, Idle) => {
                self.call_redraw_events_cleared();
            }
            (HandlingRedrawEvents, HandlingMainEvents) => {
                warn!("NewEvents emitted without explicit RedrawEventsCleared");
                self.call_redraw_events_cleared();
                self.call_new_events(false);
            }
            (HandlingRedrawEvents, Destroyed) => {
                self.call_redraw_events_cleared();
                self.call_event_handler(Event::LoopDestroyed);
            }
            (Destroyed, _) => panic!("cannot move state from Destroyed"),
        }
    }
unsafe fn move_state_to ( & self , new_runner_state : RunnerState ) { use RunnerState :: { Destroyed , HandlingMainEvents , HandlingRedrawEvents , Idle , Uninitialized , } ; match ( self . runner_state . replace ( new_runner_state ) , new_runner_state , ) { ( Uninitialized , Uninitialized ) | ( Idle , Idle ) | ( HandlingMainEvents , HandlingMainEvents ) | ( HandlingRedrawEvents , HandlingRedrawEvents ) | ( Destroyed , Destroyed ) => ( ) , // State transitions that initialize the event loop. ( Uninitialized , HandlingMainEvents ) => { self . call_new_events ( true ) ; } ( Uninitialized , HandlingRedrawEvents ) => { self . call_new_events ( true ) ; self . call_event_handler ( Event :: MainEventsCleared ) ; } ( Uninitialized , Idle ) => { self . call_new_events ( true ) ; self . call_event_handler ( Event :: MainEventsCleared ) ; self . call_redraw_events_cleared ( ) ; } ( Uninitialized , Destroyed ) => { self . call_new_events ( true ) ; self . call_event_handler ( Event :: MainEventsCleared ) ; self . call_redraw_events_cleared ( ) ; self . call_event_handler ( Event :: LoopDestroyed ) ; } ( _ , Uninitialized ) => panic ! ( " " ) , // State transitions that start the event handling process. ( Idle , HandlingMainEvents ) => { self . call_new_events ( false ) ; } ( Idle , HandlingRedrawEvents ) => { self . call_new_events ( false ) ; self . call_event_handler ( Event :: MainEventsCleared ) ; } ( Idle , Destroyed ) => { self . call_event_handler ( Event :: LoopDestroyed ) ; } ( HandlingMainEvents , HandlingRedrawEvents ) => { self . call_event_handler ( Event :: MainEventsCleared ) ; } ( HandlingMainEvents , Idle ) => { warn ! ( " " ) ; self . call_event_handler ( Event :: MainEventsCleared ) ; self . call_redraw_events_cleared ( ) ; } ( HandlingMainEvents , Destroyed ) => { self . call_event_handler ( Event :: MainEventsCleared ) ; self . call_redraw_events_cleared ( ) ; self . call_event_handler ( Event :: LoopDestroyed ) ; } ( HandlingRedrawEvents , Idle ) => { self . call_redraw_events_cleared ( ) ; } ( HandlingRedrawEvents , HandlingMainEvents ) => { warn ! ( " " ) ; self . call_redraw_events_cleared ( ) ; self . call_new_events ( false ) ; } ( HandlingRedrawEvents , Destroyed ) => { self . call_redraw_events_cleared ( ) ; self . call_event_handler ( Event :: LoopDestroyed ) ; } ( Destroyed , _ ) => panic ! ( " " ) , } }
Dispatch control flow events (`NewEvents`, `MainEventsCleared`, `RedrawEventsCleared`, and
`LoopDestroyed`) as necessary to bring the internal `RunnerState` to the new runner state.
Dispatch control flow events ( ` NewEvents ` ` MainEventsCleared ` ` RedrawEventsCleared ` and ` LoopDestroyed ` ) as necessary to bring the internal ` RunnerState ` to the new runner state .
&self
new_runner_state
RunnerState
&self
new_runner_state
RunnerState