[][src]Attribute Macro wlroots_dehandle::wlroots_dehandle


Attribute to automatically call the run method on handles with the remaining block of code.

The name of the variable you want to use as the upgraded handle should be provided as an argument to the attribute. It does not need to be the same as the handle variable.

The syntax in the code should be use $handle as $upgraded_handle. E.g the variable in the code that stores the handle should go on the left and the variable you used in the attribute declaration should go on the right.


If the handle is invalid (e.g. default constructed, or is a dangling handle) then your code will panic!.

If this is undesirable, please use the non-proc macro with_handles!.


This example is not tested
impl InputManagerHandler for InputManager {
    #[wlroots_dehandle(compositor, keyboard, seat)]
    fn keyboard_added(&mut self,
                      compositor_handle: CompositorHandle,
                      keyboard: KeyboardHandle)
                      -> Option<Box<Keyboard Handler>> {
            use compositor_handle as compositor;
            use keyboard as keyboard;
            let server: &mut ::Server = compositor.into();
            // Now that we have at least one keyboard, update the seat capabilities.
            let server_seat = &server.seat.seat;
            use server_seat as seat;
            let mut capabilities = seat.capabilities();
        // Due to some weird closure inference rules, this has to be outside
        // of the above block.