aboutsummaryrefslogtreecommitdiff
path: root/examples/async/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/async/main.rs')
-rw-r--r--examples/async/main.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/async/main.rs b/examples/async/main.rs
index 3c884fe..03e36e1 100644
--- a/examples/async/main.rs
+++ b/examples/async/main.rs
@@ -7,12 +7,15 @@ use tokio::spawn;
mod animals;
mod bootstrap;
+mod food;
mod interfaces;
use bootstrap::bootstrap;
use interfaces::dog::IDog;
use interfaces::human::IHuman;
+use crate::interfaces::food::IFoodFactory;
+
#[tokio::main]
async fn main() -> Result<()>
{
@@ -29,6 +32,15 @@ async fn main() -> Result<()>
dog.woof();
}
+ let food_factory = di_container
+ .get::<IFoodFactory>()
+ .await?
+ .threadsafe_factory()?;
+
+ let food = food_factory();
+
+ food.eat();
+
spawn(async move {
let human = di_container.get::<dyn IHuman>().await?.transient()?;