Skip to main content

BorrowAppContext

Trait BorrowAppContext 

Source
pub trait BorrowAppContext {
    // Required methods
    fn set_global<T: Global>(&mut self, global: T);
    fn update_global<G, R>(
        &mut self,
        f: impl FnOnce(&mut G, &mut Self) -> R,
    ) -> R
       where G: Global;
    fn update_default_global<G, R>(
        &mut self,
        f: impl FnOnce(&mut G, &mut Self) -> R,
    ) -> R
       where G: Global + Default;
}
Expand description

A helper trait for auto-implementing certain methods on contexts that can be used interchangeably.

Required Methods§

Source

fn set_global<T: Global>(&mut self, global: T)

Set a global value on the context.

Source

fn update_global<G, R>(&mut self, f: impl FnOnce(&mut G, &mut Self) -> R) -> R
where G: Global,

Updates the global state of the given type.

Source

fn update_default_global<G, R>( &mut self, f: impl FnOnce(&mut G, &mut Self) -> R, ) -> R
where G: Global + Default,

Updates the global state of the given type, creating a default if it didn’t exist before.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<C> BorrowAppContext for C
where C: BorrowMut<App>,