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/animal_store.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 examples/unbound/animal_store.rs (limited to 'examples/unbound/animal_store.rs') diff --git a/examples/unbound/animal_store.rs b/examples/unbound/animal_store.rs new file mode 100644 index 0000000..b2127e4 --- /dev/null +++ b/examples/unbound/animal_store.rs @@ -0,0 +1,34 @@ +use syrette::injectable; +use syrette::ptr::{SingletonPtr, TransientPtr}; + +use crate::interfaces::animal_store::IAnimalStore; +use crate::interfaces::cat::ICat; +use crate::interfaces::dog::IDog; + +pub struct AnimalStore +{ + dog: SingletonPtr, + cat: TransientPtr, +} + +#[injectable] +impl AnimalStore +{ + fn new(dog: SingletonPtr, cat: TransientPtr) -> Self + { + Self { dog, cat } + } +} + +impl IAnimalStore for AnimalStore +{ + fn get_dog(&self) -> SingletonPtr + { + self.dog.clone() + } + + fn get_cat(&self) -> &TransientPtr + { + &self.cat + } +} -- cgit v1.2.3-18-g5258