client-toolkit icon indicating copy to clipboard operation
client-toolkit copied to clipboard

delegate macros as attributes

Open l4l opened this issue 1 year ago • 4 comments

For now for implementing a certain feature, one need to implement trait, then call a delegate_<feat>! on the structure which seems a little bit redundant, so instead of this:

impl<T: Xyz + 'static> ShmHandler for SimpleWindow<T> {
    fn shm_state(&mut self) -> &mut Shm {
        &mut self.shm
    }
}

delegate_shm!(@<T: Xyz + 'static> SimpleWindow<T>);

it would be nice to have this instead:

#[sctk::delegate]
impl<T: Xyz + 'static> ShmHandler for SimpleWindow<T> {
    fn shm_state(&mut self) -> &mut Shm {
        &mut self.shm
    }
}

l4l avatar Oct 29 '23 19:10 l4l