use std::fmt::Debug; use auto_delegate_impl::delegate; use crate::sub_module::addr::Addr; use crate::sub_module::increment::Increment; #[delegate] pub trait Readable where T: Debug + Default, { fn read(&self) -> &T; } pub struct MultipleChild { num: usize, value: T, } impl Default for MultipleChild { fn default() -> Self { Self { num: 0, value: T::default(), } } } impl Addr for MultipleChild where T: Debug + Default, { fn add(&self, x1: usize, x2: usize) -> usize { x1 + x2 } } impl Increment for MultipleChild where T: Debug + Default, { fn increment(&mut self) -> usize { self.num += 1; self.num } } impl Readable for MultipleChild where T: Debug + Default, { fn read(&self) -> &T { &self.value } }