diff options
Diffstat (limited to 'src/interfaces/async_injectable.rs')
-rw-r--r-- | src/interfaces/async_injectable.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/interfaces/async_injectable.rs b/src/interfaces/async_injectable.rs index 4c18487..3600bac 100644 --- a/src/interfaces/async_injectable.rs +++ b/src/interfaces/async_injectable.rs @@ -1,5 +1,6 @@ //! Interface for structs that can be injected into or be injected to. use std::fmt::Debug; +use std::future::ready; use crate::errors::injectable::InjectableError; use crate::future::BoxFuture; @@ -32,3 +33,19 @@ impl<DIContainerT> Debug for dyn AsyncInjectable<DIContainerT> f.write_str("{}") } } + +impl<T, DIContainerT> AsyncInjectable<DIContainerT> for T +where + T: Default + 'static + Send + Sync, +{ + fn resolve<'di_container, 'fut>( + _: &'di_container DIContainerT, + _: DependencyHistory, + ) -> BoxFuture<'fut, Result<TransientPtr<Self>, InjectableError>> + where + Self: Sized + 'fut, + 'di_container: 'fut, + { + Box::pin(ready(Ok(TransientPtr::new(Self::default())))) + } +} |