diff options
Diffstat (limited to 'examples/factory')
-rw-r--r-- | examples/factory/bootstrap.rs | 11 | ||||
-rw-r--r-- | examples/factory/interfaces/user.rs | 4 |
2 files changed, 6 insertions, 9 deletions
diff --git a/examples/factory/bootstrap.rs b/examples/factory/bootstrap.rs index 19fad81..f8bef6e 100644 --- a/examples/factory/bootstrap.rs +++ b/examples/factory/bootstrap.rs @@ -4,11 +4,8 @@ use std::rc::Rc; use syrette::ptr::TransientPtr; use syrette::DIContainer; -// Interfaces use crate::interfaces::user::{IUser, IUserFactory}; use crate::interfaces::user_manager::IUserManager; -// -// Concrete implementations use crate::user::User; use crate::user_manager::UserManager; @@ -20,14 +17,14 @@ pub fn bootstrap() -> Result<Rc<DIContainer>, Box<dyn Error>> .bind::<dyn IUserManager>() .to::<UserManager>()?; - di_container.bind::<IUserFactory>().to_factory( - &|name, date_of_birth, password| { + di_container.bind::<IUserFactory>().to_factory(&|_| { + Box::new(move |name, date_of_birth, password| { let user: TransientPtr<dyn IUser> = TransientPtr::new(User::new(name, date_of_birth, password)); user - }, - )?; + }) + })?; Ok(di_container) } diff --git a/examples/factory/interfaces/user.rs b/examples/factory/interfaces/user.rs index 70cd632..aafd0cb 100644 --- a/examples/factory/interfaces/user.rs +++ b/examples/factory/interfaces/user.rs @@ -1,5 +1,5 @@ use syrette::factory; -use syrette::interfaces::factory::IFactory; +use syrette::ptr::TransientPtr; pub trait IUser { @@ -10,4 +10,4 @@ pub trait IUser #[factory] pub type IUserFactory = - dyn IFactory<(&'static str, &'static str, &'static str), dyn IUser>; + dyn Fn(&'static str, &'static str, &'static str) -> TransientPtr<dyn IUser>; |