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

Method with_initialized_state

aspen/src/context_stack/context.rs:72–87  ·  view source on GitHub ↗
(
        &self,
        callback: impl FnOnce(&mut State, &Self) -> Result,
    )

Source from the content-addressed store, hash-verified

70 }
71
72 pub fn with_initialized_state<State: Any, Result>(
73 &self,
74 callback: impl FnOnce(&mut State, &Self) -> Result,
75 ) -> Result {
76 let mut states = self.states.borrow_mut();
77 let state = states
78 .get_mut(&self.element_token)
79 .expect(&format!(
80 "Tried to get state that hasn't be initialized for {:?}",
81 &self.element_token
82 ))
83 .downcast_mut()
84 .expect("Tried to get state with different type than previous fetch");
85
86 callback(state, self)
87 }
88
89 pub fn with_state<State: Any + Default, Result>(
90 &self,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected