StateAsyncGetMutOrInsert

Trait StateAsyncGetMutOrInsert 

Source
pub trait StateAsyncGetMutOrInsert: State {
    // Required method
    fn get_mut_or_insert_with<T>(
        &self,
        get_data: impl FnOnce() -> T + Send,
    ) -> impl Future<Output = impl DerefMut> + Send
       where T: 'static + Send + Sync;

    // Provided methods
    fn get_mut_or_insert<T>(
        &self,
        data: T,
    ) -> impl Future<Output = impl DerefMut> + Send
       where T: 'static + Send + Sync { ... }
    fn get_mut_or_insert_default<T>(
        &self,
    ) -> impl Future<Output = impl DerefMut> + Send
       where T: 'static + Send + Sync + Default { ... }
}
Expand description

Get data mutably or insert (async immutable version)

Required Methods§

Source

fn get_mut_or_insert_with<T>( &self, get_data: impl FnOnce() -> T + Send, ) -> impl Future<Output = impl DerefMut> + Send
where T: 'static + Send + Sync,

Returns data of type T mutably, inserts if not found

Provided Methods§

Source

fn get_mut_or_insert<T>( &self, data: T, ) -> impl Future<Output = impl DerefMut> + Send
where T: 'static + Send + Sync,

Returns data of type T mutably, inserts if not found

Source

fn get_mut_or_insert_default<T>( &self, ) -> impl Future<Output = impl DerefMut> + Send
where T: 'static + Send + Sync + Default,

Returns data of type T mutably, inserts default if not found

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§