diff options
| author | HampusM <hampus@hampusmat.com> | 2023-10-04 11:10:36 +0200 | 
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2023-10-04 11:10:36 +0200 | 
| commit | b0a1af1e312f23eff7fe68ae17132ccded5cf31c (patch) | |
| tree | 316f9177fcc7d3d73051750d9d87a6e965b6a26c /examples/async-factory | |
| parent | 613bf4a8a094df6f048cc8b1fcf2fc425abddd99 (diff) | |
refactor!: remove mutex in AsyncDIContainer
BREAKING CHANGE: Multiple async DI container binding builder & binding configurator functions are no longer async
Diffstat (limited to 'examples/async-factory')
| -rw-r--r-- | examples/async-factory/main.rs | 18 | 
1 files changed, 7 insertions, 11 deletions
diff --git a/examples/async-factory/main.rs b/examples/async-factory/main.rs index f0365a1..83f79f0 100644 --- a/examples/async-factory/main.rs +++ b/examples/async-factory/main.rs @@ -75,18 +75,15 @@ async fn main() -> Result<()>  {      let mut di_container = AsyncDIContainer::new(); -    di_container -        .bind::<IFooFactory>() -        .to_async_factory(&|_| { -            Box::new(|cnt| { -                Box::pin(async move { -                    let foo_ptr = Box::new(Foo::new(cnt)); +    di_container.bind::<IFooFactory>().to_async_factory(&|_| { +        Box::new(|cnt| { +            Box::pin(async move { +                let foo_ptr = Box::new(Foo::new(cnt)); -                    foo_ptr as Box<dyn IFoo> -                }) +                foo_ptr as Box<dyn IFoo>              })          }) -        .await?; +    })?;      di_container          .bind::<dyn IPerson>() @@ -101,8 +98,7 @@ async fn main() -> Result<()>                      person as TransientPtr<dyn IPerson>                  })              }) -        }) -        .await?; +        })?;      let foo_factory = di_container          .get::<IFooFactory>()  | 
