aboutsummaryrefslogtreecommitdiff
path: root/examples/basic/animals/human.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-07-22 13:25:45 +0200
committerHampusM <hampus@hampusmat.com>2022-07-22 13:25:45 +0200
commit4cb3884e24b3cba3347ff93475bbabd6fe18d2fa (patch)
tree2fa5e6d81de9dc39bd11d64797914e5d305d98e2 /examples/basic/animals/human.rs
parent157f38bc2287dcb9a8b21ef3d5e33c569dc5136e (diff)
refactor: make factories an optional feature
Diffstat (limited to 'examples/basic/animals/human.rs')
-rw-r--r--examples/basic/animals/human.rs20
1 files changed, 3 insertions, 17 deletions
diff --git a/examples/basic/animals/human.rs b/examples/basic/animals/human.rs
index 5bd2f8f..00574a3 100644
--- a/examples/basic/animals/human.rs
+++ b/examples/basic/animals/human.rs
@@ -1,8 +1,7 @@
use syrette::injectable;
-use syrette::ptr::{FactoryPtr, InterfacePtr};
+use syrette::ptr::InterfacePtr;
use crate::interfaces::cat::ICat;
-use crate::interfaces::cow::{CowFactory, ICow};
use crate::interfaces::dog::IDog;
use crate::interfaces::human::IHuman;
@@ -10,23 +9,14 @@ pub struct Human
{
dog: InterfacePtr<dyn IDog>,
cat: InterfacePtr<dyn ICat>,
- cow_factory: FactoryPtr<CowFactory>,
}
#[injectable(IHuman)]
impl Human
{
- pub fn new(
- dog: InterfacePtr<dyn IDog>,
- cat: InterfacePtr<dyn ICat>,
- cow_factory: FactoryPtr<CowFactory>,
- ) -> Self
+ pub fn new(dog: InterfacePtr<dyn IDog>, cat: InterfacePtr<dyn ICat>) -> Self
{
- Self {
- dog,
- cat,
- cow_factory,
- }
+ Self { dog, cat }
}
}
@@ -41,9 +31,5 @@ impl IHuman for Human
println!("Hi kitty!");
self.cat.meow();
-
- let cow: Box<dyn ICow> = (self.cow_factory)(3);
-
- cow.moo();
}
}