From 55f5e8ca096467be2db895b459760ec34b63fce6 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 20 Aug 2022 18:06:42 +0200 Subject: docs: add example for displaying a unbound interface error --- examples/unbound/animals/human.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 examples/unbound/animals/human.rs (limited to 'examples/unbound/animals/human.rs') diff --git a/examples/unbound/animals/human.rs b/examples/unbound/animals/human.rs new file mode 100644 index 0000000..d9b848b --- /dev/null +++ b/examples/unbound/animals/human.rs @@ -0,0 +1,35 @@ +use syrette::injectable; +use syrette::ptr::{SingletonPtr, TransientPtr}; + +use crate::interfaces::cat::ICat; +use crate::interfaces::dog::IDog; +use crate::interfaces::human::IHuman; + +pub struct Human +{ + dog: SingletonPtr, + cat: TransientPtr, +} + +#[injectable(IHuman)] +impl Human +{ + pub fn new(dog: SingletonPtr, cat: TransientPtr) -> Self + { + Self { dog, cat } + } +} + +impl IHuman for Human +{ + fn make_pets_make_sounds(&self) + { + println!("Hi doggy!"); + + self.dog.woof(); + + println!("Hi kitty!"); + + self.cat.meow(); + } +} -- cgit v1.2.3-18-g5258