MCPcopy Create free account
hub / github.com/Kethku/Pando / with_initialized_state

Method with_initialized_state

aspen/src/context_stack/draw_context.rs:434–446  ·  view source on GitHub ↗
(&mut self, callback: impl FnOnce(&mut State, &mut DrawContext<'a>) -> Result)

Source from the content-addressed store, hash-verified

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,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected