Function rudi::transient_async

source ·
pub fn transient_async<T, C>(constructor: C) -> TransientAsyncProvider<T>
where C: for<'a> Fn(&'a mut Context) -> BoxFuture<'a, T> + 'static,
Expand description

Create a TransientAsyncProvider instance

§Example

use rudi::{transient_async, FutureExt, TransientAsyncProvider};

#[derive(Clone)]
struct A(i32);

fn main() {
    let _: TransientAsyncProvider<A> =
        transient_async(|cx| async { A(cx.resolve_async().await) }.boxed());
}