diff options
| author | HampusM <hampus@hampusmat.com> | 2023-10-04 12:51:06 +0200 | 
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2023-10-04 12:52:22 +0200 | 
| commit | 0f2756536e8fc311119da2af5b4dcc33f41bec6e (patch) | |
| tree | 0964efe0eaf855017c67fae52da8672a47becc65 /examples | |
| parent | c936439bfac9e35958f685a52abb51d781e70a7c (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 'examples')
| -rw-r--r-- | examples/async-factory/main.rs | 5 | ||||
| -rw-r--r-- | examples/async/bootstrap.rs | 4 | ||||
| -rw-r--r-- | examples/async/interfaces/food.rs | 2 | ||||
| -rw-r--r-- | examples/factory/interfaces/user.rs | 2 | ||||
| -rw-r--r-- | examples/with-3rd-party/bootstrap.rs | 4 | 
5 files changed, 3 insertions, 14 deletions
diff --git a/examples/async-factory/main.rs b/examples/async-factory/main.rs index 83f79f0..2b796cc 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::future::BoxFuture;  use syrette::ptr::TransientPtr; -use syrette::{declare_default_factory, factory, AsyncDIContainer}; +use syrette::AsyncDIContainer;  use tokio::time::sleep;  trait IFoo: Send + Sync @@ -15,7 +15,6 @@ trait IFoo: Send + Sync      fn bar(&self);  } -#[factory(threadsafe = true)]  type IFooFactory =      dyn Fn(i32) -> BoxFuture<'static, TransientPtr<dyn IFoo>> + Send + Sync; @@ -68,8 +67,6 @@ impl IPerson for Person      }  } -declare_default_factory!(dyn IPerson, async = true); -  #[tokio::main]  async fn main() -> Result<()>  { diff --git a/examples/async/bootstrap.rs b/examples/async/bootstrap.rs index 6fbe831..07e1bf8 100644 --- a/examples/async/bootstrap.rs +++ b/examples/async/bootstrap.rs @@ -1,5 +1,5 @@  use syrette::ptr::TransientPtr; -use syrette::{declare_default_factory, AsyncDIContainer}; +use syrette::AsyncDIContainer;  use crate::animals::cat::Cat;  use crate::animals::dog::Dog; @@ -10,8 +10,6 @@ use crate::interfaces::dog::IDog;  use crate::interfaces::food::{IFood, IFoodFactory};  use crate::interfaces::human::IHuman; -declare_default_factory!(dyn ICat, threadsafe = true); -  pub async fn bootstrap() -> Result<AsyncDIContainer, anyhow::Error>  {      let mut di_container = AsyncDIContainer::new(); diff --git a/examples/async/interfaces/food.rs b/examples/async/interfaces/food.rs index 9d88083..21ea568 100644 --- a/examples/async/interfaces/food.rs +++ b/examples/async/interfaces/food.rs @@ -1,4 +1,3 @@ -use syrette::factory;  use syrette::ptr::TransientPtr;  pub trait IFood: Send + Sync @@ -6,5 +5,4 @@ pub trait IFood: Send + Sync      fn eat(&self);  } -#[factory(threadsafe = true)]  pub type IFoodFactory = dyn Fn() -> TransientPtr<dyn IFood> + Send + Sync; diff --git a/examples/factory/interfaces/user.rs b/examples/factory/interfaces/user.rs index aafd0cb..5a60317 100644 --- a/examples/factory/interfaces/user.rs +++ b/examples/factory/interfaces/user.rs @@ -1,4 +1,3 @@ -use syrette::factory;  use syrette::ptr::TransientPtr;  pub trait IUser @@ -8,6 +7,5 @@ pub trait IUser      fn get_password(&self) -> &'static str;  } -#[factory]  pub type IUserFactory =      dyn Fn(&'static str, &'static str, &'static str) -> TransientPtr<dyn IUser>; diff --git a/examples/with-3rd-party/bootstrap.rs b/examples/with-3rd-party/bootstrap.rs index 5cd0f85..26386f5 100644 --- a/examples/with-3rd-party/bootstrap.rs +++ b/examples/with-3rd-party/bootstrap.rs @@ -1,14 +1,12 @@  use std::error::Error;  use syrette::ptr::TransientPtr; -use syrette::{declare_default_factory, DIContainer}; +use syrette::DIContainer;  use third_party_lib::Shuriken;  use crate::interfaces::ninja::INinja;  use crate::ninja::Ninja; -declare_default_factory!(Shuriken); -  pub fn bootstrap() -> Result<DIContainer, Box<dyn Error>>  {      let mut di_container = DIContainer::new();  | 
