Skip to main content

carry_forward

Function carry_forward 

Source
pub fn carry_forward<K, V>(current: &mut HashMap<K, V>, prior: HashMap<K, V>)
where K: Hash + Eq,
Expand description

Merge a pre-reload registry snapshot back under the entries the reloaded script just registered, so a reload never silently loses a registration.

current holds what the new top level registered and wins every collision; prior fills in the rest. Every ScriptHost::replace implementation runs this over its handler, event-handler, and derivation maps on the success path. The registrations that need it are the ones an app makes from on_start: that callback fires once at app construction and never again, so its handlers cannot re-register themselves during a reload.

One case stays stale until the app restarts: renaming a handler function together with the on(...) call that binds it leaves the old name in the map under its old key, because nothing in the new source collides with it.