(
&mut self,
callback: impl FnOnce(&mut State, &mut DrawContext<'a>) -> Result,
)
| 446 | } |
| 447 | |
| 448 | pub fn with_state<State: Any + Default, Result>( |
| 449 | &mut self, |
| 450 | callback: impl FnOnce(&mut State, &mut DrawContext<'a>) -> Result, |
| 451 | ) -> Result { |
| 452 | let mut states = self.states.borrow_mut(); |
| 453 | let state = match states.entry(self.element_token) { |
| 454 | Entry::Occupied(entry) => { |
| 455 | entry.into_mut().downcast_mut().expect("Tried to get state with different type than was previously inserted") |
| 456 | }, |
| 457 | Entry::Vacant(entry) => { |
| 458 | entry.insert(Box::new(State::default())).downcast_mut().unwrap() |
| 459 | } |
| 460 | }; |
| 461 | |
| 462 | callback(state, self) |
| 463 | } |
| 464 | |
| 465 | pub(crate) fn child<'b>( |
| 466 | &'b mut self, |
nothing calls this directly
no outgoing calls
no test coverage detected