aboutsummaryrefslogtreecommitdiff
path: root/examples/unbound/animals
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-08-21 14:19:07 +0200
committerHampusM <hampus@hampusmat.com>2022-08-21 18:17:51 +0200
commit8c66b98bca6ed0a2990903fe8e0ea72def5c7be8 (patch)
treedeed78171051262dba7e8d97eba73a9aaf04dd5e /examples/unbound/animals
parentb3e1b993b028bbfa73638236cfbdb50ee478d3f0 (diff)
refactor!: change errors to be more sane
BREAKING CHANGE: Major improvements have been made to error types and the error_stack crate is no longer used
Diffstat (limited to 'examples/unbound/animals')
-rw-r--r--examples/unbound/animals/human.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/examples/unbound/animals/human.rs b/examples/unbound/animals/human.rs
index d9b848b..56764d3 100644
--- a/examples/unbound/animals/human.rs
+++ b/examples/unbound/animals/human.rs
@@ -1,22 +1,20 @@
use syrette::injectable;
-use syrette::ptr::{SingletonPtr, TransientPtr};
+use syrette::ptr::TransientPtr;
-use crate::interfaces::cat::ICat;
-use crate::interfaces::dog::IDog;
+use crate::interfaces::animal_store::IAnimalStore;
use crate::interfaces::human::IHuman;
pub struct Human
{
- dog: SingletonPtr<dyn IDog>,
- cat: TransientPtr<dyn ICat>,
+ animal_store: TransientPtr<dyn IAnimalStore>,
}
#[injectable(IHuman)]
impl Human
{
- pub fn new(dog: SingletonPtr<dyn IDog>, cat: TransientPtr<dyn ICat>) -> Self
+ pub fn new(animal_store: TransientPtr<dyn IAnimalStore>) -> Self
{
- Self { dog, cat }
+ Self { animal_store }
}
}
@@ -24,12 +22,16 @@ impl IHuman for Human
{
fn make_pets_make_sounds(&self)
{
+ let dog = self.animal_store.get_dog();
+
println!("Hi doggy!");
- self.dog.woof();
+ dog.woof();
+
+ let cat = self.animal_store.get_cat();
println!("Hi kitty!");
- self.cat.meow();
+ cat.meow();
}
}