fn push(&mut self, state: Box<dyn State<T, E>>, data: StateData<'_, T>) {
        if self.running {
            let StateData {
                context: state_manager,
                world,
                data,
            } = data;
            if let Some(state) = self.state_stack.last_mut() {
                state.on_pause(StateData {
                    context: state_manager,
                    world,
                    data,
                });
            }

            self.state_stack.push(state);

            // State was just pushed, thus pop will always succeed
            let new_state = self.state_stack.last_mut().unwrap();
            new_state.on_start(StateData {
                context: state_manager,
                world,
                data,
            });
        }
    }
/// Pauses the active state and pushes a new state onto the state stack.
Pauses the active state and pushes a new state onto the state stack.
Pauses the active state and pushes a new state onto the state stack .
fn push(&mut self, state: Box<dyn State<T, E>>, data: StateData<'_, T>) {
        if self.running {
            let StateData {
                context: state_manager,
                world,
                data,
            } = data;
            if let Some(state) = self.state_stack.last_mut() {
                state.on_pause(StateData {
                    context: state_manager,
                    world,
                    data,
                });
            }
            self.state_stack.push(state);
            // State was just pushed, thus pop will always succeed
            let new_state = self.state_stack.last_mut().unwrap();
            new_state.on_start(StateData {
                context: state_manager,
                world,
                data,
            });
        }
    }
fn push ( & mut self , state : Box < dyn State < T , E > > , data : StateData < ' _ , T > ) { if self . running { let StateData { context : state_manager , world , data , } = data ; if let Some ( state ) = self . state_stack . last_mut ( ) { state . on_pause ( StateData { context : state_manager , world , data , } ) ; } self . state_stack . push ( state ) ; // State was just pushed, thus pop will always succeed let new_state = self . state_stack . last_mut ( ) . unwrap ( ) ; new_state . on_start ( StateData { context : state_manager , world , data , } ) ; } }
Pauses the active state and pushes a new state onto the state stack.
Pauses the active state and pushes a new state onto the state stack .
&mut self
state
Box<dyn State<T, E>>
data
StateData<'_, T>
&mut self
state
Box<dyn State<T, E>>
data
StateData<'_, T>