aboutsummaryrefslogtreecommitdiff
path: root/examples/async
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-10-04 11:10:36 +0200
committerHampusM <hampus@hampusmat.com>2023-10-04 11:10:36 +0200
commitb0a1af1e312f23eff7fe68ae17132ccded5cf31c (patch)
tree316f9177fcc7d3d73051750d9d87a6e965b6a26c /examples/async
parent613bf4a8a094df6f048cc8b1fcf2fc425abddd99 (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')
-rw-r--r--examples/async/bootstrap.rs31
1 files changed, 12 insertions, 19 deletions
diff --git a/examples/async/bootstrap.rs b/examples/async/bootstrap.rs
index d26876a..6fbe831 100644
--- a/examples/async/bootstrap.rs
+++ b/examples/async/bootstrap.rs
@@ -18,34 +18,27 @@ pub async fn bootstrap() -> Result<AsyncDIContainer, anyhow::Error>
di_container
.bind::<dyn IDog>()
- .to::<Dog>()
- .await?
+ .to::<Dog>()?
.in_singleton_scope()
.await?;
- di_container
- .bind::<dyn ICat>()
- .to_default_factory(&|_| {
- Box::new(|| {
- let cat: TransientPtr<dyn ICat> = TransientPtr::new(Cat::new());
+ di_container.bind::<dyn ICat>().to_default_factory(&|_| {
+ Box::new(|| {
+ let cat: TransientPtr<dyn ICat> = TransientPtr::new(Cat::new());
- cat
- })
+ cat
})
- .await?;
+ })?;
- di_container.bind::<dyn IHuman>().to::<Human>().await?;
+ di_container.bind::<dyn IHuman>().to::<Human>()?;
- di_container
- .bind::<IFoodFactory>()
- .to_factory(&|_| {
- Box::new(|| {
- let food: Box<dyn IFood> = Box::new(Food::new());
+ di_container.bind::<IFoodFactory>().to_factory(&|_| {
+ Box::new(|| {
+ let food: Box<dyn IFood> = Box::new(Food::new());
- food
- })
+ food
})
- .await?;
+ })?;
Ok(di_container)
}