(
&mut self,
callback: impl FnOnce(&mut State, &mut EventContext<'a>) -> Result,
)
| 157 | } |
| 158 | |
| 159 | pub fn with_state<State: Any + Default, Result>( |
| 160 | &mut self, |
| 161 | callback: impl FnOnce(&mut State, &mut EventContext<'a>) -> Result, |
| 162 | ) -> Result { |
| 163 | let mut states = self.states.borrow_mut(); |
| 164 | let state = match states.entry(self.element_token) { |
| 165 | Entry::Occupied(entry) => entry |
| 166 | .into_mut() |
| 167 | .downcast_mut() |
| 168 | .expect("Tried to get state with different type than was previously inserted"), |
| 169 | Entry::Vacant(entry) => entry |
| 170 | .insert(Box::new(State::default())) |
| 171 | .downcast_mut() |
| 172 | .unwrap(), |
| 173 | }; |
| 174 | |
| 175 | callback(state, self) |
| 176 | } |
| 177 | |
| 178 | pub fn for_region<'b>(&'b mut self, region: &'b MouseRegion) -> EventContext<'b> { |
| 179 | let child_cx: AttachedContext<'b> = self |
nothing calls this directly
no outgoing calls
no test coverage detected