Skip to main content

provide_context

Function provide_context 

Source
pub fn provide_context<'s, T: 'static>(
    cx: &mut Cx<'s, '_>,
    value: Handle<'s, T>,
    children: impl FnOnce(&mut Cx<'s, '_>),
)
Expand description

Make value visible to use_context::<T> inside children.

The binding lasts exactly as long as children runs. What is stored is the slot id, not the handle, so the store needs no lifetime parameter and no unsafe.