From b0a1af1e312f23eff7fe68ae17132ccded5cf31c Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 4 Oct 2023 11:10:36 +0200 Subject: refactor!: remove mutex in AsyncDIContainer BREAKING CHANGE: Multiple async DI container binding builder & binding configurator functions are no longer async --- examples/async/bootstrap.rs | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'examples/async') 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 di_container .bind::() - .to::() - .await? + .to::()? .in_singleton_scope() .await?; - di_container - .bind::() - .to_default_factory(&|_| { - Box::new(|| { - let cat: TransientPtr = TransientPtr::new(Cat::new()); + di_container.bind::().to_default_factory(&|_| { + Box::new(|| { + let cat: TransientPtr = TransientPtr::new(Cat::new()); - cat - }) + cat }) - .await?; + })?; - di_container.bind::().to::().await?; + di_container.bind::().to::()?; - di_container - .bind::() - .to_factory(&|_| { - Box::new(|| { - let food: Box = Box::new(Food::new()); + di_container.bind::().to_factory(&|_| { + Box::new(|| { + let food: Box = Box::new(Food::new()); - food - }) + food }) - .await?; + })?; Ok(di_container) } -- cgit v1.2.3-18-g5258