Skip to main content

UpdateGlobal

Trait UpdateGlobal 

Source
pub trait UpdateGlobal {
    // Required methods
    fn update_global<C, F, R>(cx: &mut C, update: F) -> R
       where C: BorrowAppContext,
             F: FnOnce(&mut Self, &mut C) -> R;
    fn set_global<C>(cx: &mut C, global: Self)
       where C: BorrowAppContext;
}
Expand description

A trait for updating a global value in the context.

Required Methods§

Source

fn update_global<C, F, R>(cx: &mut C, update: F) -> R
where C: BorrowAppContext, F: FnOnce(&mut Self, &mut C) -> R,

Updates the global instance of the implementing type using the provided closure.

This method provides the closure with mutable access to the context and the global simultaneously.

Source

fn set_global<C>(cx: &mut C, global: Self)

Set the global instance of the implementing type.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§