From 8c66b98bca6ed0a2990903fe8e0ea72def5c7be8 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 21 Aug 2022 14:19:07 +0200 Subject: 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 --- examples/unbound/animals/human.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'examples/unbound/animals') 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, - cat: TransientPtr, + animal_store: TransientPtr, } #[injectable(IHuman)] impl Human { - pub fn new(dog: SingletonPtr, cat: TransientPtr) -> Self + pub fn new(animal_store: TransientPtr) -> 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(); } } -- cgit v1.2.3-18-g5258