aboutsummaryrefslogtreecommitdiff
path: root/src/provider/blocking.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-10-04 12:51:06 +0200
committerHampusM <hampus@hampusmat.com>2023-10-04 12:52:22 +0200
commit0f2756536e8fc311119da2af5b4dcc33f41bec6e (patch)
tree0964efe0eaf855017c67fae52da8672a47becc65 /src/provider/blocking.rs
parentc936439bfac9e35958f685a52abb51d781e70a7c (diff)
refactor!: remove factory & declare_default_factory macros
BREAKING CHANGE: The factory and the declare_default_factory macros have been removed. They are no longer needed to use factories
Diffstat (limited to 'src/provider/blocking.rs')
-rw-r--r--src/provider/blocking.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/provider/blocking.rs b/src/provider/blocking.rs
index 5710a65..bde3be5 100644
--- a/src/provider/blocking.rs
+++ b/src/provider/blocking.rs
@@ -13,9 +13,9 @@ pub enum Providable<DIContainerType>
Transient(TransientPtr<dyn Injectable<DIContainerType>>),
Singleton(SingletonPtr<dyn Injectable<DIContainerType>>),
#[cfg(feature = "factory")]
- Factory(crate::ptr::FactoryPtr<dyn crate::private::any_factory::AnyFactory>),
+ Factory(crate::ptr::FactoryPtr<dyn crate::any_factory::AnyFactory>),
#[cfg(feature = "factory")]
- DefaultFactory(crate::ptr::FactoryPtr<dyn crate::private::any_factory::AnyFactory>),
+ DefaultFactory(crate::ptr::FactoryPtr<dyn crate::any_factory::AnyFactory>),
}
#[cfg_attr(test, mockall::automock)]
@@ -108,7 +108,7 @@ where
#[cfg(feature = "factory")]
pub struct FactoryProvider
{
- factory: crate::ptr::FactoryPtr<dyn crate::private::any_factory::AnyFactory>,
+ factory: crate::ptr::FactoryPtr<dyn crate::any_factory::AnyFactory>,
is_default_factory: bool,
}
@@ -116,7 +116,7 @@ pub struct FactoryProvider
impl FactoryProvider
{
pub fn new(
- factory: crate::ptr::FactoryPtr<dyn crate::private::any_factory::AnyFactory>,
+ factory: crate::ptr::FactoryPtr<dyn crate::any_factory::AnyFactory>,
is_default_factory: bool,
) -> Self
{
@@ -196,13 +196,21 @@ mod tests
#[cfg(feature = "factory")]
fn factory_provider_works()
{
- use crate::private::any_factory::AnyFactory;
+ use std::any::Any;
+
+ use crate::any_factory::AnyFactory;
use crate::ptr::FactoryPtr;
#[derive(Debug)]
struct FooFactory;
- impl AnyFactory for FooFactory {}
+ impl AnyFactory for FooFactory
+ {
+ fn as_any(&self) -> &dyn Any
+ {
+ self
+ }
+ }
let factory_provider = FactoryProvider::new(FactoryPtr::new(FooFactory), false);
let default_factory_provider =