2 use std::collections::HashMap;
7 fn get_type_id_of_state(&self) -> TypeId;
10 struct StateMachine<EventType: Hash + Eq> {
11 current_state: Box<dyn State<EventType = EventType>>,
13 HashMap<TypeId, HashMap<EventType, fn() -> Box<dyn State<EventType = EventType>>>>,
16 impl<EventType: Hash + Eq> StateMachine<EventType> {
17 fn inner_process_event(&mut self, event: EventType) -> Result<(), i8> {
18 let new_state_creation_function = self
21 .find(|(&event_typeid, _)| event_typeid == self.current_state.get_type_id_of_state())
25 .find(|(&event_type, _)| event == event_type)
26 //~^ ERROR cannot move out of a shared reference
30 self.current_state = new_state_creation_function();