From 14e45fe9aa2431120cfd6a7240f8bb94e45e730d Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 4 Aug 2023 15:24:32 +0200 Subject: refactor!: remove async_closure macro from API BREAKING CHANGE: The async_closure macro has been removed. This is because it is completely out of scope for this crate --- examples/async-factory/main.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'examples/async-factory') diff --git a/examples/async-factory/main.rs b/examples/async-factory/main.rs index b9beded..76efb2f 100644 --- a/examples/async-factory/main.rs +++ b/examples/async-factory/main.rs @@ -7,7 +7,7 @@ use std::time::Duration; use anyhow::Result; use syrette::di_container::asynchronous::prelude::*; use syrette::ptr::TransientPtr; -use syrette::{async_closure, declare_default_factory, factory}; +use syrette::{declare_default_factory, factory}; use tokio::time::sleep; trait IFoo: Send + Sync @@ -77,10 +77,12 @@ async fn main() -> Result<()> di_container .bind::() .to_async_factory(&|_| { - async_closure!(|cnt| { - let foo_ptr = Box::new(Foo::new(cnt)); + Box::new(|cnt| { + Box::pin(async move { + let foo_ptr = Box::new(Foo::new(cnt)); - foo_ptr as Box + foo_ptr as Box + }) }) }) .await?; @@ -88,13 +90,15 @@ async fn main() -> Result<()> di_container .bind::() .to_async_default_factory(&|_| { - async_closure!(|| { - // Do some time demanding thing... - sleep(Duration::from_secs(1)).await; + Box::new(|| { + Box::pin(async { + // Do some time demanding thing... + sleep(Duration::from_secs(1)).await; - let person = TransientPtr::new(Person::new("Bob".to_string())); + let person = TransientPtr::new(Person::new("Bob".to_string())); - person as TransientPtr + person as TransientPtr + }) }) }) .await?; -- cgit v1.2.3-18-g5258