diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/async/animals/human.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/examples/async/animals/human.rs b/examples/async/animals/human.rs index fc98ed8..5bc4903 100644 --- a/examples/async/animals/human.rs +++ b/examples/async/animals/human.rs @@ -1,5 +1,8 @@ +use std::time::Duration; + use syrette::injectable; use syrette::ptr::{ThreadsafeSingletonPtr, TransientPtr}; +use tokio::time::sleep; use crate::interfaces::cat::ICat; use crate::interfaces::dog::IDog; @@ -14,9 +17,14 @@ pub struct Human #[injectable(IHuman, async = true)] impl Human { - pub fn new(dog: ThreadsafeSingletonPtr<dyn IDog>, cat: TransientPtr<dyn ICat>) - -> Self + pub async fn new( + dog: ThreadsafeSingletonPtr<dyn IDog>, + cat: TransientPtr<dyn ICat>, + ) -> Self { + // The human needs some rest first + sleep(Duration::from_secs(1)).await; + Self { dog, cat } } } |