pub fn transition(&mut self, action: &A) {
        let current_value = self.value.clone();

        if let Some(transition) = self.states.get(&self.value) {
            match transition.context {
                Some(fn_context) => {
                    self.context = fn_context(self.context, action.to_owned(), self.value);
                }
                None => {}
            }

            match transition.on {
                Some(fn_on) => {
                    self.value = fn_on(self.context, action.to_owned(), self.value);
                }
                None => {}
            }
        }

        if &self.value != &current_value {
            // Run the on_entry for the newest state
            if let Some(transition) = self.states.get(&self.value) {
                match transition.on_entry {
                    Some(fn_on_entry) => {
                        self.context = fn_on_entry(self.context, action.to_owned(), self.value);
                    }
                    None => {}
                }
            }

            // Run the on_entry for the newest state
            if let Some(transition) = self.states.get(&current_value) {
                match transition.on_exit {
                    Some(fn_on_exit) => {
                        self.context = fn_on_exit(self.context, action.to_owned(), self.value);
                    }
                    None => {}
                }
            }
        }
    }
/// Send an action to the state machine
Send an action to the state machine
Send an action to the state machine
pub fn transition(&mut self, action: &A) {
        let current_value = self.value.clone();
        if let Some(transition) = self.states.get(&self.value) {
            match transition.context {
                Some(fn_context) => {
                    self.context = fn_context(self.context, action.to_owned(), self.value);
                }
                None => {}
            }
            match transition.on {
                Some(fn_on) => {
                    self.value = fn_on(self.context, action.to_owned(), self.value);
                }
                None => {}
            }
        }
        if &self.value != &current_value {
            // Run the on_entry for the newest state
            if let Some(transition) = self.states.get(&self.value) {
                match transition.on_entry {
                    Some(fn_on_entry) => {
                        self.context = fn_on_entry(self.context, action.to_owned(), self.value);
                    }
                    None => {}
                }
            }
            // Run the on_entry for the newest state
            if let Some(transition) = self.states.get(&current_value) {
                match transition.on_exit {
                    Some(fn_on_exit) => {
                        self.context = fn_on_exit(self.context, action.to_owned(), self.value);
                    }
                    None => {}
                }
            }
        }
    }
pub fn transition ( & mut self , action : & A ) { let current_value = self . value . clone ( ) ; if let Some ( transition ) = self . states . get ( & self . value ) { match transition . context { Some ( fn_context ) => { self . context = fn_context ( self . context , action . to_owned ( ) , self . value ) ; } None => { } } match transition . on { Some ( fn_on ) => { self . value = fn_on ( self . context , action . to_owned ( ) , self . value ) ; } None => { } } } if & self . value != & current_value { // Run the on_entry for the newest state if let Some ( transition ) = self . states . get ( & self . value ) { match transition . on_entry { Some ( fn_on_entry ) => { self . context = fn_on_entry ( self . context , action . to_owned ( ) , self . value ) ; } None => { } } } // Run the on_entry for the newest state if let Some ( transition ) = self . states . get ( & current_value ) { match transition . on_exit { Some ( fn_on_exit ) => { self . context = fn_on_exit ( self . context , action . to_owned ( ) , self . value ) ; } None => { } } } } }
Send an action to the state machine
Send an action to the state machine
&mut self
action
&A
&mut self
action
&A