(&mut self, callback: impl FnOnce(&mut State, &mut DrawContext<'a>) -> Result)
| 432 | } |
| 433 | |
| 434 | pub fn with_initialized_state<State: Any, Result>(&mut self, callback: impl FnOnce(&mut State, &mut DrawContext<'a>) -> Result) -> Result { |
| 435 | let mut states = self.states.borrow_mut(); |
| 436 | let state = states |
| 437 | .get_mut(&self.element_token) |
| 438 | .expect(&format!( |
| 439 | "Tried to get state that hasn't be initialized for {:?}", |
| 440 | &self.element_token |
| 441 | )) |
| 442 | .downcast_mut() |
| 443 | .expect("Tried to get state with different type than previous fetch"); |
| 444 | |
| 445 | callback(state, self) |
| 446 | } |
| 447 | |
| 448 | pub fn with_state<State: Any + Default, Result>( |
| 449 | &mut self, |
nothing calls this directly
no outgoing calls
no test coverage detected