diff options
| author | HampusM <hampus@hampusmat.com> | 2022-09-17 16:12:45 +0200 | 
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2022-09-17 16:12:45 +0200 | 
| commit | 8651f84f205da7a89f2fc7333d1dd8de0d80a22b (patch) | |
| tree | a178427abb442e897d21f654db71cc8135236920 /examples/async/main.rs | |
| parent | c1e682c25c24be3174d44ceb95b0537c38299d0c (diff) | |
refactor!: make async DI container be used inside of a Arc
BREAKING CHANGE: The async DI container is to be used inside of a Arc & it also no longer implements Default
Diffstat (limited to 'examples/async/main.rs')
| -rw-r--r-- | examples/async/main.rs | 14 | 
1 files changed, 2 insertions, 12 deletions
diff --git a/examples/async/main.rs b/examples/async/main.rs index f72ff39..3c884fe 100644 --- a/examples/async/main.rs +++ b/examples/async/main.rs @@ -2,11 +2,8 @@  #![deny(clippy::pedantic)]  #![allow(clippy::module_name_repetitions)] -use std::sync::Arc; -  use anyhow::Result;  use tokio::spawn; -use tokio::sync::Mutex;  mod animals;  mod bootstrap; @@ -21,12 +18,10 @@ async fn main() -> Result<()>  {      println!("Hello, world!"); -    let di_container = Arc::new(Mutex::new(bootstrap().await?)); +    let di_container = bootstrap().await?;      {          let dog = di_container -            .lock() -            .await              .get::<dyn IDog>()              .await?              .threadsafe_singleton()?; @@ -35,12 +30,7 @@ async fn main() -> Result<()>      }      spawn(async move { -        let human = di_container -            .lock() -            .await -            .get::<dyn IHuman>() -            .await? -            .transient()?; +        let human = di_container.get::<dyn IHuman>().await?.transient()?;          human.make_pets_make_sounds();  | 
